mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 02:34:38 +00:00
Users: Prime user meta in WP_User_Query class.
When querying 'fields' equal to 'all' using the `WP_User_Query` class, this returns an array of `WP_User` objects. A `WP_User` object requires user meta to be primed, as the user's role is stored in user meta. Ensure that all users meta is primed in a single request by calling the `cache_users` function when querying 'fields' equal to 'all'. Soft deprecate fields equal to `all_with_meta` as it now acts the same as 'fields' equal to 'all'. Props Spacedmonkey, peterwilsoncc, mehulkaklotar, timothyblynjacobs, furi3r. Fixes #55594. git-svn-id: https://develop.svn.wordpress.org/trunk@53655 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -155,6 +155,26 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 55594
|
||||
*/
|
||||
public function test_get_all_primed_users() {
|
||||
$filter = new MockAction();
|
||||
add_filter( 'update_user_metadata_cache', array( $filter, 'filter' ), 10, 2 );
|
||||
|
||||
new WP_User_Query(
|
||||
array(
|
||||
'include' => self::$author_ids,
|
||||
'fields' => 'all',
|
||||
)
|
||||
);
|
||||
|
||||
$args = $filter->get_args();
|
||||
$last_args = end( $args );
|
||||
$this->assertIsArray( $last_args[1] );
|
||||
$this->assertSameSets( self::$author_ids, $last_args[1], 'Ensure that user meta is primed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 39297
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user