Changeset 53655
- Timestamp:
- 07/05/2022 09:26:21 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-user-query.php
r53469 r53655 236 236 * - 'spam' (only available on multisite installs) 237 237 * - 'deleted' (only available on multisite installs) 238 * - 'all' for all fields 239 * - 'all_with_meta' to include meta fields.238 * - 'all' for all fields and loads user meta. 239 * - 'all_with_meta' Deprecated. Use 'all'. 240 240 * Default 'all'. 241 241 * @type string $who Type of users to query. Accepts 'authors'. … … 311 311 } 312 312 $this->query_fields = implode( ',', $this->query_fields ); 313 } elseif ( 'all' === $qv['fields'] ) { 314 $this->query_fields = "$wpdb->users.*"; 315 } elseif ( ! in_array( $qv['fields'], $allowed_fields, true ) ) { 313 } elseif ( 'all_with_meta' === $qv['fields'] || 'all' === $qv['fields'] || ! in_array( $qv['fields'], $allowed_fields, true ) ) { 316 314 $this->query_fields = "$wpdb->users.ID"; 317 315 } else { … … 809 807 "; 810 808 811 if ( is_array( $qv['fields'] ) || 'all' === $qv['fields']) {809 if ( is_array( $qv['fields'] ) ) { 812 810 $this->results = $wpdb->get_results( $this->request ); 813 811 } else { … … 843 841 $result->id = $result->ID; 844 842 } 845 } elseif ( 'all_with_meta' === $qv['fields'] ) {843 } elseif ( 'all_with_meta' === $qv['fields'] || 'all' === $qv['fields'] ) { 846 844 cache_users( $this->results ); 847 845 848 846 $r = array(); 849 847 foreach ( $this->results as $userid ) { 850 $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] ); 848 if ( 'all_with_meta' === $qv['fields'] ) { 849 $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] ); 850 } else { 851 $r[] = new WP_User( $userid, '', $qv['blog_id'] ); 852 } 851 853 } 852 854 853 855 $this->results = $r; 854 } elseif ( 'all' === $qv['fields'] ) {855 foreach ( $this->results as $key => $user ) {856 $this->results[ $key ] = new WP_User( $user, '', $qv['blog_id'] );857 }858 856 } 859 857 } -
trunk/tests/phpunit/tests/user/query.php
r53373 r53655 154 154 $this->assertInstanceOf( 'WP_User', $user ); 155 155 } 156 } 157 158 /** 159 * @ticket 55594 160 */ 161 public function test_get_all_primed_users() { 162 $filter = new MockAction(); 163 add_filter( 'update_user_metadata_cache', array( $filter, 'filter' ), 10, 2 ); 164 165 new WP_User_Query( 166 array( 167 'include' => self::$author_ids, 168 'fields' => 'all', 169 ) 170 ); 171 172 $args = $filter->get_args(); 173 $last_args = end( $args ); 174 $this->assertIsArray( $last_args[1] ); 175 $this->assertSameSets( self::$author_ids, $last_args[1], 'Ensure that user meta is primed' ); 156 176 } 157 177
Note: See TracChangeset
for help on using the changeset viewer.