Changeset 11705
- Timestamp:
- 09/27/2017 10:24:10 AM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-core-user.php
r11606 r11705 750 750 * Get WordPress user details for a specified user. 751 751 * 752 * @ global wpdb $wpdb WordPress database object.752 * @since 3.0.0 Results might be from cache 753 753 * 754 754 * @param int $user_id User ID. 755 * @return array Associative array.755 * @return false|object WP_User if successful, false on failure. 756 756 */ 757 757 public static function get_core_userdata( $user_id ) { 758 global $wpdb; 759 760 if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) ) 761 return false; 762 763 return $user; 758 return WP_User::get_data_by( 'id', $user_id ); 764 759 } 765 760 -
trunk/src/bp-core/classes/class-bp-user-query.php
r11376 r11705 571 571 ), $this ) ); 572 572 573 // WP_User_Query doesn't cache the data it pulls from wp_users,574 // and it does not give us a way to save queries by fetching575 // only uncached users. However, BP does cache this data, so576 // we set it here.577 foreach ( $wp_user_query->results as $u ) {578 wp_cache_set( 'bp_core_userdata_' . $u->ID, $u, 'bp' );579 }580 581 573 // We calculate total_users using a standalone query, except 582 574 // when a whitelist of user_ids is passed to the constructor. -
trunk/src/bp-members/bp-members-functions.php
r11663 r11705 215 215 } 216 216 217 $userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ); 218 219 // No cache. 220 if ( false === $userdata ) { 221 $userdata = BP_Core_User::get_core_userdata( $user_id ); 222 223 // Cache data; no-result is cached as integer 0. 224 wp_cache_set( 'bp_core_userdata_' . $user_id, false === $userdata ? 0 : $userdata, 'bp' ); 225 226 // Cached no-result, so set return value as false as expected. 227 } elseif ( 0 === $userdata ) { 228 $userdata = false; 229 } 217 // Get core user data 218 $userdata = BP_Core_User::get_core_userdata( $user_id ); 230 219 231 220 /** -
trunk/src/bp-settings/bp-settings-actions.php
r11704 r11705 179 179 // on the current page load. 180 180 if ( ( false === $email_error ) && ( false === $pass_error ) && ( wp_update_user( $update_user ) ) ) { 181 wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' );182 181 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); 183 182 } … … 455 454 456 455 if ( $email_changed ) { 457 // Delete object cache for displayed user.458 wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' );459 456 460 457 // Delete the pending email change key. -
trunk/src/bp-xprofile/bp-xprofile-functions.php
r11692 r11705 837 837 838 838 wp_update_user( array( 'ID' => $user_id, 'display_name' => $fullname ) ); 839 wp_cache_delete( 'bp_core_userdata_' . $user_id, 'bp' );840 839 } 841 840 add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
Note: See TracChangeset
for help on using the changeset viewer.