Changeset 34919
- Timestamp:
- 10/07/2015 10:41:07 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user-functions.php
r34912 r34919 1103 1103 * @since 3.0.0 1104 1104 * 1105 * @param object $user User object to be cached 1106 */ 1107 function update_user_caches($user) { 1105 * @param object|WP_User $user User object to be cached 1106 * @return bool|null Returns false on failure. 1107 */ 1108 function update_user_caches( $user ) { 1109 if ( $user instanceof WP_User ) { 1110 if ( ! $user->exists() ) { 1111 return false; 1112 } 1113 1114 $user = $user->data; 1115 } 1116 1108 1117 wp_cache_add($user->ID, $user, 'users'); 1109 1118 wp_cache_add($user->user_login, $user->ID, 'userlogins'); -
trunk/tests/phpunit/tests/user/updateUserCaches.php
r34918 r34919 51 51 $this->assertEquals( 12345, wp_cache_get( 'bar', 'userslugs' ) ); 52 52 } 53 54 /** 55 * @ticket 24635 56 */ 57 public function test_should_store_raw_data_in_users_bucket_when_passed_a_wp_user_object() { 58 global $wpdb; 59 60 $u = $this->factory->user->create(); 61 $raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) ); 62 $user_object = new WP_User( $u ); 63 64 update_user_caches( $user_object ); 65 66 $cached = wp_cache_get( $u, 'users' ); 67 $this->assertFalse( $cached instanceof WP_User ); 68 $this->assertEquals( $raw_userdata, $cached ); 69 } 53 70 }
Note: See TracChangeset
for help on using the changeset viewer.