mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Handle WP_User objects properly in update_user_caches().
We should not be storing the `WP_User` object in the cache, as it may contain usermeta and other data that's cache elsewhere. Props dd32. See #24635. git-svn-id: https://develop.svn.wordpress.org/trunk@34919 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -50,4 +50,21 @@ class Tests_User_UpdateUserCaches extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEquals( 12345, wp_cache_get( 'bar', 'userslugs' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 24635
|
||||
*/
|
||||
public function test_should_store_raw_data_in_users_bucket_when_passed_a_wp_user_object() {
|
||||
global $wpdb;
|
||||
|
||||
$u = $this->factory->user->create();
|
||||
$raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) );
|
||||
$user_object = new WP_User( $u );
|
||||
|
||||
update_user_caches( $user_object );
|
||||
|
||||
$cached = wp_cache_get( $u, 'users' );
|
||||
$this->assertFalse( $cached instanceof WP_User );
|
||||
$this->assertEquals( $raw_userdata, $cached );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user