[wp-trac] [WordPress Trac] #54728: Coding Standards fixes for WP 6.0

WordPress Trac noreply at wordpress.org
Mon Mar 21 14:27:19 UTC 2022

#54728: Coding Standards fixes for WP 6.0
 Reporter:  hellofromTonya  |       Owner:  (none)
     Type:  task (blessed)  |      Status:  new
 Priority:  normal          |   Milestone:  6.0
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:  coding-standards

Comment (by jrf):

 @SergeyBiryukov I'm not a fan of some of the recent changes.

 Splitting long queries into separate parts and joining them using
 `implode()` makes the code ''less'' readable.

 If you want to improve those, you can either use multi-line strings or use
 `sprintf()`, which both make for more readable code.

 // Original code:
 $old_request   = "SELECT $found_rows $distinct $fields FROM {$wpdb->posts}
 $join WHERE 1=1 $where $groupby $orderby $limits";

 // More readable than implode:
 $old_request   = "
     SELECT $found_rows $distinct $fields
     FROM {$wpdb->posts}
     WHERE 1=1 $where

 // Alternative:
 $old_request   = "sprintf(
     'SELECT %s %s %s FROM %s %s WHERE 1=1 %s %s %s %s',

 As for the changes from `array()` to `compact()`: '''this is a BC-break
 which should be reverted'''.
 You are changing the array which is passed to the filters from a
 numerically indexed array to an associative array and any code which is
 hooked into those filters which was approaching the array using numeric
 indexes will now be broken.

 See: https://3v4l.org/gUWOB

Ticket URL: <https://core.trac.wordpress.org/ticket/54728#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list