Ticket #5979: 5979.02.patch
File 5979.02.patch, 3.1 KB (added by , 10 years ago) |
---|
-
src/bp-core/bp-core-classes.php
464 464 * @since BuddyPress (1.7.0) 465 465 */ 466 466 public function do_wp_user_query() { 467 $fields = array( 'ID', 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name' );468 467 469 if ( is_multisite() ) {470 $fields[] = 'spam';471 $fields[] = 'deleted';472 }473 474 468 $wp_user_query = new WP_User_Query( apply_filters( 'bp_wp_user_query_args', array( 475 469 476 470 // Relevant 477 'fields' => $fields,471 'fields' => 'all_with_meta', 478 472 'include' => $this->user_ids, 479 473 480 474 // Overrides … … 483 477 484 478 ), $this ) ); 485 479 486 // WP_User_Query doesn't cache the data it pulls from wp_users,487 // and it does not give us a way to save queries by fetching488 // only uncached users. However, BP does cache this data, so489 // we set it here.490 foreach ( $wp_user_query->results as $u ) {491 wp_cache_set( 'bp_core_userdata_' . $u->ID, $u, 'bp' );492 }493 494 480 // We calculate total_users using a standalone query, except 495 481 // when a whitelist of user_ids is passed to the constructor. 496 482 // This clause covers the latter situation, and ensures that … … 1328 1314 * @return array Associative array. 1329 1315 */ 1330 1316 public static function get_core_userdata( $user_id ) { 1331 global $wpdb; 1332 1333 if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) ) 1334 return false; 1335 1336 return $user; 1317 return get_userdata( $user_id ); 1337 1318 } 1338 1319 1339 1320 /** -
src/bp-members/bp-members-functions.php
178 178 * @return array 179 179 */ 180 180 function bp_core_get_core_userdata( $user_id = 0 ) { 181 if ( empty( $user_id ) ) {182 return false;183 }184 181 185 if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {186 $userdata = BP_Core_User::get_core_userdata( $user_id );187 wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );188 } 189 return apply_filters( 'bp_core_get_core_userdata', $userdata );182 $userdata = ! empty( $user_id ) 183 ? BP_Core_User::get_core_userdata( $user_id ) 184 : false; 185 186 return apply_filters( 'bp_core_get_core_userdata', $userdata, $user_id ); 190 187 } 191 188 192 189 /** -
src/bp-settings/bp-settings-actions.php
196 196 // Clear cached data, so that the changed settings take effect 197 197 // on the current page load 198 198 if ( ( false === $email_error ) && ( false === $pass_error ) && ( wp_update_user( $update_user ) ) ) { 199 wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' );200 199 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); 201 200 } 202 201 … … 439 438 ) ); 440 439 441 440 if ( $email_changed ) { 442 // Delete object cache for displayed user443 wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' );444 441 445 442 // Delete the pending email change key 446 443 bp_delete_user_meta( bp_displayed_user_id(), 'pending_email_change' );