Coding Standards: Restore the `$pieces` variable for SQL clauses in query classes.

This is a defensive coding measure that aims to reduce confusion. With this change, `$pieces` is explicitly used for the names, and `$clauses` for the values of the clauses.

Follow-up to [52974], [53175], [53370], [53375].

Props peterwilsoncc.
See #55699.
Built from https://develop.svn.wordpress.org/trunk@53376


git-svn-id: http://core.svn.wordpress.org/trunk@52965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-05-10 11:21:09 +00:00
parent 4959a268c3
commit cb2d81f6df
5 changed files with 9 additions and 9 deletions

View File

@ -917,7 +917,7 @@ class WP_Comment_Query {
$where = implode( ' AND ', $this->sql_clauses['where'] ); $where = implode( ' AND ', $this->sql_clauses['where'] );
$clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
/** /**
* Filters the comment query clauses. * Filters the comment query clauses.
@ -927,7 +927,7 @@ class WP_Comment_Query {
* @param string[] $clauses An associative array of comment query clauses. * @param string[] $clauses An associative array of comment query clauses.
* @param WP_Comment_Query $query Current instance of WP_Comment_Query (passed by reference). * @param WP_Comment_Query $query Current instance of WP_Comment_Query (passed by reference).
*/ */
$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $clauses ), &$this ) ); $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -438,7 +438,7 @@ class WP_Network_Query {
$groupby = ''; $groupby = '';
$clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
/** /**
* Filters the network query clauses. * Filters the network query clauses.
@ -448,7 +448,7 @@ class WP_Network_Query {
* @param string[] $clauses An associative array of network query clauses. * @param string[] $clauses An associative array of network query clauses.
* @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference). * @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference).
*/ */
$clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $clauses ), &$this ) ); $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -646,7 +646,7 @@ class WP_Site_Query {
$where = implode( ' AND ', $this->sql_clauses['where'] ); $where = implode( ' AND ', $this->sql_clauses['where'] );
$clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
/** /**
* Filters the site query clauses. * Filters the site query clauses.
@ -656,7 +656,7 @@ class WP_Site_Query {
* @param string[] $clauses An associative array of site query clauses. * @param string[] $clauses An associative array of site query clauses.
* @param WP_Site_Query $query Current instance of WP_Site_Query (passed by reference). * @param WP_Site_Query $query Current instance of WP_Site_Query (passed by reference).
*/ */
$clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $clauses ), &$this ) ); $clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $pieces ), &$this ) );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -700,7 +700,7 @@ class WP_Term_Query {
$where = implode( ' AND ', $this->sql_clauses['where'] ); $where = implode( ' AND ', $this->sql_clauses['where'] );
$clauses = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' ); $pieces = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' );
/** /**
* Filters the terms query SQL clauses. * Filters the terms query SQL clauses.
@ -721,7 +721,7 @@ class WP_Term_Query {
* @param string[] $taxonomies An array of taxonomy names. * @param string[] $taxonomies An array of taxonomy names.
* @param array $args An array of term query arguments. * @param array $args An array of term query arguments.
*/ */
$clauses = apply_filters( 'terms_clauses', compact( $clauses ), $taxonomies, $args ); $clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.1-alpha-53375'; $wp_version = '6.1-alpha-53376';
/** /**
* 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.