Coding Standards: Use multi-line strings for the `$this->request` property in `wp-includes/class-wp-*-query.php`.

This further improves the readability by replacing `implode()` calls with string interpolation.

Follow-up to [52973].

Props jrf.
See #54728.
Built from https://develop.svn.wordpress.org/trunk@52977


git-svn-id: http://core.svn.wordpress.org/trunk@52566 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-03-22 14:56:05 +00:00
parent 51d4723691
commit 6f5f187574
7 changed files with 55 additions and 76 deletions

View File

@ -961,17 +961,14 @@ class WP_Comment_Query {
$this->sql_clauses['orderby'] = $orderby; $this->sql_clauses['orderby'] = $orderby;
$this->sql_clauses['limits'] = $limits; $this->sql_clauses['limits'] = $limits;
$this->request = implode( $this->request = "
' ', {$this->sql_clauses['select']}
array( {$this->sql_clauses['from']}
$this->sql_clauses['select'], {$where}
$this->sql_clauses['from'], {$this->sql_clauses['groupby']}
$where, {$this->sql_clauses['orderby']}
$this->sql_clauses['groupby'], {$this->sql_clauses['limits']}
$this->sql_clauses['orderby'], ";
$this->sql_clauses['limits'],
)
);
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
return (int) $wpdb->get_var( $this->request ); return (int) $wpdb->get_var( $this->request );

View File

@ -480,17 +480,14 @@ class WP_Network_Query {
$this->sql_clauses['orderby'] = $orderby; $this->sql_clauses['orderby'] = $orderby;
$this->sql_clauses['limits'] = $limits; $this->sql_clauses['limits'] = $limits;
$this->request = implode( $this->request = "
' ', {$this->sql_clauses['select']}
array( {$this->sql_clauses['from']}
$this->sql_clauses['select'], {$where}
$this->sql_clauses['from'], {$this->sql_clauses['groupby']}
$where, {$this->sql_clauses['orderby']}
$this->sql_clauses['groupby'], {$this->sql_clauses['limits']}
$this->sql_clauses['orderby'], ";
$this->sql_clauses['limits'],
)
);
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
return (int) $wpdb->get_var( $this->request ); return (int) $wpdb->get_var( $this->request );

View File

@ -3000,17 +3000,14 @@ class WP_Query {
$found_rows = 'SQL_CALC_FOUND_ROWS'; $found_rows = 'SQL_CALC_FOUND_ROWS';
} }
$old_request = implode( $old_request = "
' ', SELECT $found_rows $distinct $fields
array( FROM {$wpdb->posts} $join
"SELECT $found_rows $distinct $fields", WHERE 1=1 $where
"FROM {$wpdb->posts} $join", $groupby
"WHERE 1=1 $where", $orderby
$groupby, $limits
$orderby, ";
$limits,
)
);
$this->request = $old_request; $this->request = $old_request;
@ -3097,17 +3094,14 @@ class WP_Query {
if ( $split_the_query ) { if ( $split_the_query ) {
// First get the IDs and then fill in the objects. // First get the IDs and then fill in the objects.
$this->request = implode( $this->request = "
' ', SELECT $found_rows $distinct {$wpdb->posts}.ID
array( FROM {$wpdb->posts} $join
"SELECT $found_rows $distinct {$wpdb->posts}.ID", WHERE 1=1 $where
"FROM {$wpdb->posts} $join", $groupby
"WHERE 1=1 $where", $orderby
$groupby, $limits
$orderby, ";
$limits,
)
);
/** /**
* Filters the Post IDs SQL request before sending. * Filters the Post IDs SQL request before sending.

View File

@ -683,17 +683,14 @@ class WP_Site_Query {
$this->sql_clauses['orderby'] = $orderby; $this->sql_clauses['orderby'] = $orderby;
$this->sql_clauses['limits'] = $limits; $this->sql_clauses['limits'] = $limits;
$this->request = implode( $this->request = "
' ', {$this->sql_clauses['select']}
array( {$this->sql_clauses['from']}
$this->sql_clauses['select'], {$where}
$this->sql_clauses['from'], {$this->sql_clauses['groupby']}
$where, {$this->sql_clauses['orderby']}
$this->sql_clauses['groupby'], {$this->sql_clauses['limits']}
$this->sql_clauses['orderby'], ";
$this->sql_clauses['limits'],
)
);
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
return (int) $wpdb->get_var( $this->request ); return (int) $wpdb->get_var( $this->request );

View File

@ -722,16 +722,13 @@ class WP_Term_Query {
$this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : ''; $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : '';
$this->sql_clauses['limits'] = $limits; $this->sql_clauses['limits'] = $limits;
$this->request = implode( $this->request = "
' ', {$this->sql_clauses['select']}
array( {$this->sql_clauses['from']}
$this->sql_clauses['select'], {$where}
$this->sql_clauses['from'], {$this->sql_clauses['orderby']}
$where, {$this->sql_clauses['limits']}
$this->sql_clauses['orderby'], ";
$this->sql_clauses['limits'],
)
);
$this->terms = null; $this->terms = null;

View File

@ -770,16 +770,13 @@ class WP_User_Query {
$this->results = apply_filters_ref_array( 'users_pre_query', array( null, &$this ) ); $this->results = apply_filters_ref_array( 'users_pre_query', array( null, &$this ) );
if ( null === $this->results ) { if ( null === $this->results ) {
$this->request = implode( $this->request = "
' ', SELECT {$this->query_fields}
array( {$this->query_from}
"SELECT {$this->query_fields}", {$this->query_where}
$this->query_from, {$this->query_orderby}
$this->query_where, {$this->query_limit}
$this->query_orderby, ";
$this->query_limit,
)
);
if ( is_array( $qv['fields'] ) || 'all' === $qv['fields'] ) { if ( is_array( $qv['fields'] ) || 'all' === $qv['fields'] ) {
$this->results = $wpdb->get_results( $this->request ); $this->results = $wpdb->get_results( $this->request );

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-alpha-52976'; $wp_version = '6.0-alpha-52977';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.