--- a/wp/wp-includes/class-wp-user-query.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/class-wp-user-query.php Tue Dec 15 13:49:49 2020 +0100
@@ -25,7 +25,7 @@
public $query_vars = array();
/**
- * List of found user ids
+ * List of found user IDs.
*
* @since 3.1.0
* @var array
@@ -58,7 +58,7 @@
private $compat_fields = array( 'results', 'total_users' );
- // SQL clauses
+ // SQL clauses.
public $query_fields;
public $query_from;
public $query_where;
@@ -159,8 +159,9 @@
* @type string $search Search keyword. Searches for possible string matches on columns.
* When `$search_columns` is left empty, it tries to determine which
* column to search in based on search string. Default empty.
- * @type array $search_columns Array of column names to be searched. Accepts 'ID', 'login',
- * 'nicename', 'email', 'url'. Default empty array.
+ * @type array $search_columns Array of column names to be searched. Accepts 'ID', 'user_login',
+ * 'user_email', 'user_url', 'user_nicename', 'display_name'.
+ * Default empty array.
* @type string|array $orderby Field(s) to sort the retrieved users by. May be a single value,
* an array of values, or a multi-dimensional array with fields as
* keys and orders ('ASC' or 'DESC') as values. Accepted values are
@@ -179,7 +180,7 @@
* @type int $number Number of users to limit the query for. Can be used in
* conjunction with pagination. Value -1 (all) is supported, but
* should be used with caution on larger sites.
- * Default empty (all users).
+ * Default -1 (all users).
* @type int $paged When used with number, defines the page of results to return.
* Default 1.
* @type bool $count_total Whether to count the total number of users found. If pagination
@@ -241,7 +242,7 @@
$this->query_fields[] = "$wpdb->users.$field";
}
$this->query_fields = implode( ',', $this->query_fields );
- } elseif ( 'all' == $qv['fields'] ) {
+ } elseif ( 'all' === $qv['fields'] ) {
$this->query_fields = "$wpdb->users.*";
} else {
$this->query_fields = "$wpdb->users.ID";
@@ -319,7 +320,7 @@
$this->meta_query = new WP_Meta_Query();
$this->meta_query->parse_query_vars( $qv );
- if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
+ if ( isset( $qv['who'] ) && 'authors' === $qv['who'] && $blog_id ) {
$who_query = array(
'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level',
'value' => 0,
@@ -327,7 +328,8 @@
);
// Prevent extra meta query.
- $qv['blog_id'] = $blog_id = 0;
+ $qv['blog_id'] = 0;
+ $blog_id = 0;
if ( empty( $this->meta_query->queries ) ) {
$this->meta_query->queries = array( $who_query );
@@ -437,7 +439,7 @@
}
}
- // sorting
+ // Sorting.
$qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : '';
$order = $this->parse_order( $qv['order'] );
@@ -487,7 +489,7 @@
$this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array );
- // limit
+ // Limit.
if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
if ( $qv['offset'] ) {
$this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] );
@@ -536,8 +538,8 @@
/**
* Filters the columns to search in a WP_User_Query search.
*
- * The default columns depend on the search term, and include 'user_email',
- * 'user_login', 'ID', 'user_url', 'display_name', and 'user_nicename'.
+ * The default columns depend on the search term, and include 'ID', 'user_login',
+ * 'user_email', 'user_url', 'user_nicename', and 'display_name'.
*
* @since 3.6.0
*
@@ -612,7 +614,7 @@
if ( null === $this->results ) {
$this->request = "SELECT $this->query_fields $this->query_from $this->query_where $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 );
} else {
$this->results = $wpdb->get_col( $this->request );
@@ -640,7 +642,7 @@
return;
}
- if ( 'all_with_meta' == $qv['fields'] ) {
+ if ( 'all_with_meta' === $qv['fields'] ) {
cache_users( $this->results );
$r = array();
@@ -649,7 +651,7 @@
}
$this->results = $r;
- } elseif ( 'all' == $qv['fields'] ) {
+ } elseif ( 'all' === $qv['fields'] ) {
foreach ( $this->results as $key => $user ) {
$this->results[ $key ] = new WP_User( $user, '', $qv['blog_id'] );
}
@@ -678,7 +680,7 @@
* @since 3.5.0
*
* @param string $query_var Query variable key.
- * @param mixed $value Query variable value.
+ * @param mixed $value Query variable value.
*/
public function set( $query_var, $value ) {
$this->query_vars[ $query_var ] = $value;
@@ -701,12 +703,12 @@
global $wpdb;
$searches = array();
- $leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : '';
- $trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : '';
+ $leading_wild = ( 'leading' === $wild || 'both' === $wild ) ? '%' : '';
+ $trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : '';
$like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;
foreach ( $cols as $col ) {
- if ( 'ID' == $col ) {
+ if ( 'ID' === $col ) {
$searches[] = $wpdb->prepare( "$col = %s", $string );
} else {
$searches[] = $wpdb->prepare( "$col LIKE %s", $like );
@@ -754,14 +756,14 @@
$meta_query_clauses = $this->meta_query->get_clauses();
$_orderby = '';
- if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ) ) ) {
+ if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ), true ) ) {
$_orderby = 'user_' . $orderby;
- } elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ) ) ) {
+ } elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ), true ) ) {
$_orderby = $orderby;
- } elseif ( 'name' == $orderby || 'display_name' == $orderby ) {
+ } elseif ( 'name' === $orderby || 'display_name' === $orderby ) {
$_orderby = 'display_name';
- } elseif ( 'post_count' == $orderby ) {
- // todo: avoid the JOIN
+ } elseif ( 'post_count' === $orderby ) {
+ // @todo Avoid the JOIN.
$where = get_posts_by_author_sql( 'post' );
$this->query_from .= " LEFT OUTER JOIN (
SELECT post_author, COUNT(*) as post_count
@@ -771,11 +773,11 @@
) p ON ({$wpdb->users}.ID = p.post_author)
";
$_orderby = 'post_count';
- } elseif ( 'ID' == $orderby || 'id' == $orderby ) {
+ } elseif ( 'ID' === $orderby || 'id' === $orderby ) {
$_orderby = 'ID';
- } elseif ( 'meta_value' == $orderby || $this->get( 'meta_key' ) == $orderby ) {
+ } elseif ( 'meta_value' === $orderby || $this->get( 'meta_key' ) == $orderby ) {
$_orderby = "$wpdb->usermeta.meta_value";
- } elseif ( 'meta_value_num' == $orderby ) {
+ } elseif ( 'meta_value_num' === $orderby ) {
$_orderby = "$wpdb->usermeta.meta_value+0";
} elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
$include = wp_parse_id_list( $this->query_vars['include'] );
@@ -826,7 +828,7 @@
* @return mixed Property.
*/
public function __get( $name ) {
- if ( in_array( $name, $this->compat_fields ) ) {
+ if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name;
}
}
@@ -841,7 +843,7 @@
* @return mixed Newly-set property.
*/
public function __set( $name, $value ) {
- if ( in_array( $name, $this->compat_fields ) ) {
+ if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name = $value;
}
}
@@ -855,7 +857,7 @@
* @return bool Whether the property is set.
*/
public function __isset( $name ) {
- if ( in_array( $name, $this->compat_fields ) ) {
+ if ( in_array( $name, $this->compat_fields, true ) ) {
return isset( $this->$name );
}
}
@@ -868,7 +870,7 @@
* @param string $name Property to unset.
*/
public function __unset( $name ) {
- if ( in_array( $name, $this->compat_fields ) ) {
+ if ( in_array( $name, $this->compat_fields, true ) ) {
unset( $this->$name );
}
}
@@ -878,13 +880,13 @@
*
* @since 4.0.0
*
- * @param string $name Method to call.
- * @param array $arguments Arguments to pass when calling.
+ * @param string $name Method to call.
+ * @param array $arguments Arguments to pass when calling.
* @return mixed Return value of the callback, false otherwise.
*/
public function __call( $name, $arguments ) {
if ( 'get_search_sql' === $name ) {
- return call_user_func_array( array( $this, $name ), $arguments );
+ return $this->get_search_sql( ...$arguments );
}
return false;
}