From 47c2d0ff8349e034db22fe0e33bea5ab4dfb8100 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 26 Apr 2022 14:02:14 +0000 Subject: [PATCH] Docs: Add missing documentation for `WP_*_Query::get_search_sql()` method parameters. Includes renaming the `$cols` parameter to `$columns` for consistency across the classes. Follow-up to [42876], [53272-53276]. See #54729. git-svn-id: https://develop.svn.wordpress.org/trunk@53280 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-comment-query.php | 14 +++++++------- src/wp-includes/class-wp-term-query.php | 4 ++-- src/wp-includes/class-wp-user-query.php | 18 +++++++++--------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index 8fd48f1dac..96d82d2510 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -1126,24 +1126,24 @@ class WP_Comment_Query { } /** - * Used internally to generate an SQL string for searching across multiple columns + * Used internally to generate an SQL string for searching across multiple columns. * * @since 3.1.0 * * @global wpdb $wpdb WordPress database abstraction object. * - * @param string $search - * @param array $cols - * @return string + * @param string $search Search string. + * @param string[] $columns Array of columns to search. + * @return string Search SQL. */ - protected function get_search_sql( $search, $cols ) { + protected function get_search_sql( $search, $columns ) { global $wpdb; $like = '%' . $wpdb->esc_like( $search ) . '%'; $searches = array(); - foreach ( $cols as $col ) { - $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); + foreach ( $columns as $column ) { + $searches[] = $wpdb->prepare( "$column LIKE %s", $like ); } return ' AND (' . implode( ' OR ', $searches ) . ')'; diff --git a/src/wp-includes/class-wp-term-query.php b/src/wp-includes/class-wp-term-query.php index 95b308cd92..7e4c06c0df 100644 --- a/src/wp-includes/class-wp-term-query.php +++ b/src/wp-includes/class-wp-term-query.php @@ -1068,8 +1068,8 @@ class WP_Term_Query { * * @global wpdb $wpdb WordPress database abstraction object. * - * @param string $search - * @return string + * @param string $search Search string. + * @return string Search SQL. */ protected function get_search_sql( $search ) { global $wpdb; diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index ebfdfc3aea..3d6b28bcc3 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -868,13 +868,13 @@ class WP_User_Query { * * @global wpdb $wpdb WordPress database abstraction object. * - * @param string $search - * @param array $cols - * @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site. - * Single site allows leading and trailing wildcards, Network Admin only trailing. + * @param string $search Search string. + * @param string[] $columns Array of columns to search. + * @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site. + * Single site allows leading and trailing wildcards, Network Admin only trailing. * @return string */ - protected function get_search_sql( $search, $cols, $wild = false ) { + protected function get_search_sql( $search, $columns, $wild = false ) { global $wpdb; $searches = array(); @@ -882,11 +882,11 @@ class WP_User_Query { $trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : ''; $like = $leading_wild . $wpdb->esc_like( $search ) . $trailing_wild; - foreach ( $cols as $col ) { - if ( 'ID' === $col ) { - $searches[] = $wpdb->prepare( "$col = %s", $search ); + foreach ( $columns as $column ) { + if ( 'ID' === $column ) { + $searches[] = $wpdb->prepare( "$column = %s", $search ); } else { - $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); + $searches[] = $wpdb->prepare( "$column LIKE %s", $like ); } }