From fbf8cb73ecdb0488898f79be25c3d321362377d2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 21 Mar 2022 12:03:29 +0000 Subject: [PATCH] Coding Standards: Wrap the `$this->request` property in `wp-includes/class-wp-*-query.php`. This aims to improve readability by fitting the values on a single screen to avoid horizontal scrolling. See #54728. git-svn-id: https://develop.svn.wordpress.org/trunk@52973 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-comment-query.php | 12 ++++++++++- src/wp-includes/class-wp-network-query.php | 12 ++++++++++- src/wp-includes/class-wp-query.php | 25 ++++++++++++++++++++-- src/wp-includes/class-wp-site-query.php | 12 ++++++++++- src/wp-includes/class-wp-term-query.php | 11 +++++++++- src/wp-includes/class-wp-user-query.php | 11 +++++++++- 6 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index ad5fb010d39d..5fc8745e3a21 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -960,7 +960,17 @@ protected function get_comment_ids() { $this->sql_clauses['orderby'] = $orderby; $this->sql_clauses['limits'] = $limits; - $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + $this->request = implode( + ' ', + array( + $this->sql_clauses['select'], + $this->sql_clauses['from'], + $where, + $this->sql_clauses['groupby'], + $this->sql_clauses['orderby'], + $this->sql_clauses['limits'], + ) + ); if ( $this->query_vars['count'] ) { return (int) $wpdb->get_var( $this->request ); diff --git a/src/wp-includes/class-wp-network-query.php b/src/wp-includes/class-wp-network-query.php index 94d89db1874c..41a3fe458d26 100644 --- a/src/wp-includes/class-wp-network-query.php +++ b/src/wp-includes/class-wp-network-query.php @@ -480,7 +480,17 @@ protected function get_network_ids() { $this->sql_clauses['orderby'] = $orderby; $this->sql_clauses['limits'] = $limits; - $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + $this->request = implode( + ' ', + array( + $this->sql_clauses['select'], + $this->sql_clauses['from'], + $where, + $this->sql_clauses['groupby'], + $this->sql_clauses['orderby'], + $this->sql_clauses['limits'], + ) + ); if ( $this->query_vars['count'] ) { return (int) $wpdb->get_var( $this->request ); diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index d30bc43f3413..a2562519c4bc 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -3000,7 +3000,18 @@ public function get_posts() { $found_rows = 'SQL_CALC_FOUND_ROWS'; } - $old_request = "SELECT $found_rows $distinct $fields FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits"; + $old_request = implode( + ' ', + array( + "SELECT $found_rows $distinct $fields", + "FROM {$wpdb->posts} $join", + "WHERE 1=1 $where", + $groupby, + $orderby, + $limits, + ) + ); + $this->request = $old_request; if ( ! $q['suppress_filters'] ) { @@ -3086,7 +3097,17 @@ public function get_posts() { if ( $split_the_query ) { // First get the IDs and then fill in the objects. - $this->request = "SELECT $found_rows $distinct {$wpdb->posts}.ID FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits"; + $this->request = implode( + ' ', + array( + "SELECT $found_rows $distinct {$wpdb->posts}.ID", + "FROM {$wpdb->posts} $join", + "WHERE 1=1 $where", + $groupby, + $orderby, + $limits, + ) + ); /** * Filters the Post IDs SQL request before sending. diff --git a/src/wp-includes/class-wp-site-query.php b/src/wp-includes/class-wp-site-query.php index 703c9580f1e2..24225665d451 100644 --- a/src/wp-includes/class-wp-site-query.php +++ b/src/wp-includes/class-wp-site-query.php @@ -683,7 +683,17 @@ protected function get_site_ids() { $this->sql_clauses['orderby'] = $orderby; $this->sql_clauses['limits'] = $limits; - $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + $this->request = implode( + ' ', + array( + $this->sql_clauses['select'], + $this->sql_clauses['from'], + $where, + $this->sql_clauses['groupby'], + $this->sql_clauses['orderby'], + $this->sql_clauses['limits'], + ) + ); if ( $this->query_vars['count'] ) { return (int) $wpdb->get_var( $this->request ); diff --git a/src/wp-includes/class-wp-term-query.php b/src/wp-includes/class-wp-term-query.php index 426c54a07650..2a52fcd602ea 100644 --- a/src/wp-includes/class-wp-term-query.php +++ b/src/wp-includes/class-wp-term-query.php @@ -722,7 +722,16 @@ public function get_terms() { $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : ''; $this->sql_clauses['limits'] = $limits; - $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + $this->request = implode( + ' ', + array( + $this->sql_clauses['select'], + $this->sql_clauses['from'], + $where, + $this->sql_clauses['orderby'], + $this->sql_clauses['limits'], + ) + ); $this->terms = null; diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index ac6465c5f170..f1ca521efcf7 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -770,7 +770,16 @@ public function query() { $this->results = apply_filters_ref_array( 'users_pre_query', array( null, &$this ) ); if ( null === $this->results ) { - $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; + $this->request = implode( + ' ', + array( + "SELECT {$this->query_fields}", + $this->query_from, + $this->query_where, + $this->query_orderby, + $this->query_limit, + ) + ); if ( is_array( $qv['fields'] ) || 'all' === $qv['fields'] ) { $this->results = $wpdb->get_results( $this->request );