Ticket #5733: 5733.06.patch
| File 5733.06.patch, 84.0 KB (added by , 11 years ago) |
|---|
-
src/bp-activity/bp-activity-admin.php
542 542 $result = $activity->save(); 543 543 544 544 // Clear the activity stream first page cache, in case this activity's timestamp was changed 545 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );545 bp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 546 546 547 547 // Check for any error during activity save 548 548 if ( false === $result ) -
src/bp-activity/bp-activity-cache.php
42 42 * @param BP_Activity_Activity $activity 43 43 */ 44 44 function bp_activity_clear_cache_for_activity( $activity ) { 45 wp_cache_delete( $activity->id, 'bp_activity' );45 bp_cache_delete( $activity->id, 'bp_activity' ); 46 46 } 47 47 add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' ); 48 48 … … 55 55 */ 56 56 function bp_activity_clear_cache_for_deleted_activity( $deleted_ids ) { 57 57 foreach ( (array) $deleted_ids as $deleted_id ) { 58 wp_cache_delete( $deleted_id, 'bp_activity' );58 bp_cache_delete( $deleted_id, 'bp_activity' ); 59 59 } 60 60 } 61 61 add_action( 'bp_activity_deleted_activities', 'bp_activity_clear_cache_for_deleted_activity' ); -
src/bp-activity/bp-activity-classes.php
137 137 public function populate() { 138 138 global $wpdb, $bp; 139 139 140 $row = wp_cache_get( $this->id, 'bp_activity' );140 $row = bp_cache_get( $this->id, 'bp_activity' ); 141 141 142 142 if ( false === $row ) { 143 143 $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) ); 144 144 145 wp_cache_set( $this->id, $row, 'bp_activity' );145 bp_cache_set( $this->id, $row, 'bp_activity' ); 146 146 } 147 147 148 148 if ( ! empty( $row ) ) { … … 645 645 // Put that data into the placeholders created earlier, 646 646 // and add it to the cache 647 647 foreach ( (array) $queried_adata as $adata ) { 648 wp_cache_set( $adata->id, $adata, 'bp_activity' );648 bp_cache_set( $adata->id, $adata, 'bp_activity' ); 649 649 } 650 650 } 651 651 652 652 // Now fetch data from the cache 653 653 foreach ( $activity_ids as $activity_id ) { 654 $activities[] = wp_cache_get( $activity_id, 'bp_activity' );654 $activities[] = bp_cache_get( $activity_id, 'bp_activity' ); 655 655 } 656 656 657 657 // Then fetch user data … … 1269 1269 $top_level_parent_id = $activity_id; 1270 1270 } 1271 1271 1272 $comments = wp_cache_get( $activity_id, 'bp_activity_comments' );1272 $comments = bp_cache_get( $activity_id, 'bp_activity_comments' ); 1273 1273 1274 1274 // We store the string 'none' to cache the fact that the 1275 1275 // activity item has no comments … … 1394 1394 $cache_value = $comments; 1395 1395 } 1396 1396 1397 wp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );1397 bp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' ); 1398 1398 } 1399 1399 1400 1400 return $comments; -
src/bp-activity/bp-activity-functions.php
1396 1396 * @see BP_Activity_Activity::get() For more information on accepted arguments 1397 1397 * and the format of the returned value. 1398 1398 * @uses wp_parse_args() 1399 * @uses wp_cache_get()1400 * @uses wp_cache_set()1399 * @uses bp_cache_get() 1400 * @uses bp_cache_set() 1401 1401 * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity} 1402 1402 * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook. 1403 1403 * … … 1441 1441 // Attempt to return a cached copy of the first page of sitewide activity. 1442 1442 if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) { 1443 1443 1444 $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );1444 $activity = bp_cache_get( 'bp_activity_sitewide_front', 'bp' ); 1445 1445 if ( false === $activity ) { 1446 1446 1447 1447 $activity = BP_Activity_Activity::get( array( … … 1462 1462 'count_total' => $r['count_total'], 1463 1463 ) ); 1464 1464 1465 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );1465 bp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); 1466 1466 } 1467 1467 1468 1468 } else { … … 1561 1561 * @uses wp_parse_args() 1562 1562 * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity} 1563 1563 * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity} 1564 * @uses wp_cache_delete()1564 * @uses bp_cache_delete() 1565 1565 * @uses do_action() To call the 'bp_activity_add' hook 1566 1566 * 1567 1567 * @param array $args { … … 1646 1646 // If this is an activity comment, rebuild the tree 1647 1647 if ( 'activity_comment' === $activity->type ) { 1648 1648 // Also clear the comment cache for the parent activity ID 1649 wp_cache_delete( $activity->item_id, 'bp_activity_comments' );1649 bp_cache_delete( $activity->item_id, 'bp_activity_comments' ); 1650 1650 1651 1651 BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id ); 1652 1652 } 1653 1653 1654 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );1654 bp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 1655 1655 1656 1656 /** 1657 1657 * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID. … … 2002 2002 * @uses bp_activity_add() 2003 2003 * @uses apply_filters() To call the 'bp_activity_comment_action' hook. 2004 2004 * @uses apply_filters() To call the 'bp_activity_comment_content' hook. 2005 * @uses wp_cache_delete()2005 * @uses bp_cache_delete() 2006 2006 * @uses do_action() To call the 'bp_activity_comment_posted' hook. 2007 2007 * 2008 2008 * @param array $args { … … 2086 2086 ) ); 2087 2087 2088 2088 // Comment caches are stored only with the top-level item 2089 wp_cache_delete( $activity_id, 'bp_activity_comments' );2089 bp_cache_delete( $activity_id, 'bp_activity_comments' ); 2090 2090 2091 2091 // Walk the tree to clear caches for all parent items 2092 2092 $clear_id = $r['parent_id']; 2093 2093 while ( $clear_id != $activity_id ) { 2094 2094 $clear_object = new BP_Activity_Activity( $clear_id ); 2095 wp_cache_delete( $clear_id, 'bp_activity' );2095 bp_cache_delete( $clear_id, 'bp_activity' ); 2096 2096 $clear_id = intval( $clear_object->secondary_item_id ); 2097 2097 } 2098 wp_cache_delete( $activity_id, 'bp_activity' );2098 bp_cache_delete( $activity_id, 'bp_activity' ); 2099 2099 2100 2100 /** 2101 2101 * Fires near the end of an activity comment posting, before the returning of the comment ID. … … 2185 2185 * @uses bp_delete_user_meta() 2186 2186 * @uses do_action() To call the 'bp_activity_delete' hook. 2187 2187 * @uses do_action() To call the 'bp_activity_deleted_activities' hook. 2188 * @uses wp_cache_delete()2188 * @uses bp_cache_delete() 2189 2189 * 2190 2190 * @param array $args To delete specific activity items, use 2191 2191 * $args = array( 'id' => $ids ); … … 2257 2257 */ 2258 2258 do_action( 'bp_activity_deleted_activities', $activity_ids_deleted ); 2259 2259 2260 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );2260 bp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 2261 2261 2262 2262 return true; 2263 2263 } … … 2398 2398 } 2399 2399 2400 2400 // Purge comment cache for the root activity update 2401 wp_cache_delete( $activity_id, 'bp_activity_comments' );2401 bp_cache_delete( $activity_id, 'bp_activity_comments' ); 2402 2402 2403 2403 // Recalculate the comment tree 2404 2404 BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id ); … … 2632 2632 $activity->is_spam = 1; 2633 2633 2634 2634 // Clear the activity stream first page cache 2635 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );2635 bp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 2636 2636 2637 2637 // Clear the activity comment cache for this activity item 2638 wp_cache_delete( $activity->id, 'bp_activity_comments' );2638 bp_cache_delete( $activity->id, 'bp_activity_comments' ); 2639 2639 2640 2640 // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity 2641 2641 if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) { … … 2679 2679 $activity->is_spam = 0; 2680 2680 2681 2681 // Clear the activity stream first page cache 2682 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );2682 bp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 2683 2683 2684 2684 // Clear the activity comment cache for this activity item 2685 wp_cache_delete( $activity->id, 'bp_activity_comments' );2685 bp_cache_delete( $activity->id, 'bp_activity_comments' ); 2686 2686 2687 2687 // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity 2688 2688 if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) { -
src/bp-activity/bp-activity-loader.php
362 362 363 363 parent::setup_actions(); 364 364 } 365 366 /** 367 * Setup cache groups 368 * 369 * @since BuddyPress (2.2.0) 370 */ 371 public function setup_cache_groups() { 372 373 // Global groups 374 wp_cache_add_global_groups( array( 375 'bp_activity', 376 'bp_activity_comments', 377 'activity_meta' 378 ) ); 379 380 parent::setup_cache_groups(); 381 } 365 382 } 366 383 367 384 /** -
src/bp-blogs/bp-blogs-cache.php
44 44 */ 45 45 function bp_blogs_clear_blog_object_cache( $blog_id = 0, $user_id = 0 ) { 46 46 if ( ! empty( $user_id ) ) { 47 wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );48 wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );47 bp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' ); 48 bp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' ); 49 49 } 50 50 51 wp_cache_delete( 'bp_total_blogs', 'bp' );51 bp_cache_delete( 'bp_total_blogs', 'bp' ); 52 52 } 53 53 54 54 // List actions to clear object caches on -
src/bp-blogs/bp-blogs-functions.php
128 128 foreach ( (array) $blog_ids as $blog_id ) { 129 129 130 130 // Ensure that the cache is clear after the table TRUNCATE above 131 wp_cache_delete( $blog_id, 'blog_meta' );131 bp_cache_delete( $blog_id, 'blog_meta' ); 132 132 133 133 // Get all users 134 134 $users = get_users( array( … … 1144 1144 * @return int $count Total blog count. 1145 1145 */ 1146 1146 function bp_blogs_total_blogs() { 1147 $count = wp_cache_get( 'bp_total_blogs', 'bp' );1147 $count = bp_cache_get( 'bp_total_blogs', 'bp' ); 1148 1148 1149 1149 if ( false === $count ) { 1150 1150 $blogs = BP_Blogs_Blog::get_all(); 1151 1151 $count = $blogs['total']; 1152 wp_cache_set( 'bp_total_blogs', $count, 'bp' );1152 bp_cache_set( 'bp_total_blogs', $count, 'bp' ); 1153 1153 } 1154 1154 return $count; 1155 1155 } … … 1173 1173 return 0; 1174 1174 } 1175 1175 1176 $count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' );1176 $count = bp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' ); 1177 1177 if ( false === $count ) { 1178 1178 $count = BP_Blogs_Blog::total_blog_count_for_user( $user_id ); 1179 wp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, 'bp' );1179 bp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, 'bp' ); 1180 1180 } 1181 1181 1182 1182 return $count; -
src/bp-blogs/bp-blogs-loader.php
272 272 } 273 273 274 274 /** 275 * Setup cache groups 276 * 277 * @since BuddyPress (2.2.0) 278 */ 279 public function setup_cache_groups() { 280 281 // Global groups 282 wp_cache_add_global_groups( array( 283 'blog_meta' 284 ) ); 285 286 parent::setup_cache_groups(); 287 } 288 289 /** 275 290 * Set up the tracking arguments for the 'post' post type. 276 291 * 277 292 * @since BuddyPress (2.2.0) -
src/bp-core/bp-core-cache.php
105 105 * Clear all cached objects for a user, or those that a user is part of. 106 106 */ 107 107 function bp_core_clear_user_object_cache( $user_id ) { 108 wp_cache_delete( 'bp_user_' . $user_id, 'bp' );108 bp_cache_delete( 'bp_user_' . $user_id, 'bp' ); 109 109 } 110 110 111 111 /** 112 112 * Clear member count caches and transients. 113 113 */ 114 114 function bp_core_clear_member_count_caches() { 115 wp_cache_delete( 'bp_total_member_count', 'bp' );115 bp_cache_delete( 'bp_total_member_count', 'bp' ); 116 116 delete_transient( 'bp_active_member_count' ); 117 117 } 118 118 add_action( 'bp_core_activated_user', 'bp_core_clear_member_count_caches' ); … … 144 144 return; 145 145 } 146 146 147 wp_cache_delete( 'directory_pages', 'bp' );147 bp_cache_delete( 'directory_pages', 'bp' ); 148 148 } 149 149 add_action( 'save_post', 'bp_core_clear_directory_pages_cache_page_edit' ); 150 150 … … 157 157 */ 158 158 function bp_core_clear_directory_pages_cache_settings_edit( $option ) { 159 159 if ( 'bp-pages' === $option ) { 160 wp_cache_delete( 'directory_pages', 'bp' );160 bp_cache_delete( 'directory_pages', 'bp' ); 161 161 } 162 162 } 163 163 add_action( 'update_option', 'bp_core_clear_directory_pages_cache_settings_edit' ); … … 181 181 ) ); 182 182 183 183 if ( in_array( $option, $keys ) ) { 184 wp_cache_delete( 'root_blog_options', 'bp' );184 bp_cache_delete( 'root_blog_options', 'bp' ); 185 185 } 186 186 } 187 187 add_action( 'update_option', 'bp_core_clear_root_options_cache' ); … … 203 203 204 204 foreach ( $item_ids as $item_id ) { 205 205 $item_id = (int) $item_id; 206 if ( false === wp_cache_get( $item_id, $cache_group ) ) {206 if ( false === bp_cache_get( $item_id, $cache_group ) ) { 207 207 $uncached[] = $item_id; 208 208 } 209 209 } … … 302 302 $cache[ $uncached_id ] = array(); 303 303 } 304 304 305 wp_cache_set( $uncached_id, $cache[ $uncached_id ], $cache_group );305 bp_cache_set( $uncached_id, $cache[ $uncached_id ], $cache_group ); 306 306 } 307 307 } 308 308 -
src/bp-core/bp-core-classes.php
542 542 // only uncached users. However, BP does cache this data, so 543 543 // we set it here. 544 544 foreach ( $wp_user_query->results as $u ) { 545 wp_cache_set( 'bp_core_userdata_' . $u->ID, $u, 'bp' );545 bp_cache_set( 'bp_core_userdata_' . $u->ID, $u, 'bp' ); 546 546 } 547 547 548 548 // We calculate total_users using a standalone query, except … … 884 884 } 885 885 886 886 // Cache a few things that are fetched often 887 wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );888 wp_cache_set( 'bp_user_email_' . $this->id, $this->email,'bp' );889 wp_cache_set( 'bp_user_url_'. $this->id, $this->user_url, 'bp' );887 bp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' ); 888 bp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' ); 889 bp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' ); 890 890 891 891 $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) ); 892 892 $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) ); … … 1416 1416 $last_activities = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, date_recorded FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity' AND user_id IN ({$user_ids_sql}) LIMIT {$user_count}", $bp->members->id ) ); 1417 1417 1418 1418 foreach ( $last_activities as $last_activity ) { 1419 wp_cache_set( $last_activity->user_id, array(1419 bp_cache_set( $last_activity->user_id, array( 1420 1420 'user_id' => $last_activity->user_id, 1421 1421 'date_recorded' => $last_activity->date_recorded, 1422 1422 'activity_id' => $last_activity->id, … … 1427 1427 // Fetch all user data from the cache 1428 1428 $retval = array(); 1429 1429 foreach ( $user_ids as $user_id ) { 1430 $retval[ $user_id ] = wp_cache_get( $user_id, 'bp_last_activity' );1430 $retval[ $user_id ] = bp_cache_get( $user_id, 'bp_last_activity' ); 1431 1431 } 1432 1432 1433 1433 return $retval; … … 1520 1520 } 1521 1521 1522 1522 // set cache 1523 wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );1523 bp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' ); 1524 1524 1525 1525 return $updated; 1526 1526 } … … 1557 1557 ) 1558 1558 ); 1559 1559 1560 wp_cache_delete( $user_id, 'bp_last_activity' ); 1561 No newline at end of file 1560 bp_cache_delete( $user_id, 'bp_last_activity' ); 1562 1561 1563 1562 return $deleted; 1564 1563 } -
src/bp-core/bp-core-functions.php
443 443 global $wpdb; 444 444 445 445 // Look in cache first 446 $pages = wp_cache_get( 'directory_pages', 'bp' );446 $pages = bp_cache_get( 'directory_pages', 'bp' ); 447 447 448 448 if ( false === $pages ) { 449 449 … … 487 487 } 488 488 } 489 489 490 wp_cache_set( 'directory_pages', $pages, 'bp' );490 bp_cache_set( 'directory_pages', $pages, 'bp' ); 491 491 } 492 492 493 493 return apply_filters( 'bp_core_get_directory_pages', $pages ); -
src/bp-core/bp-core-options.php
343 343 // Check cache first - We cache here instead of using the standard WP 344 344 // settings cache because the current blog may not be the root blog, 345 345 // and it's not practical to access the cache across blogs 346 $root_blog_options_meta = wp_cache_get( 'root_blog_options', 'bp' );346 $root_blog_options_meta = bp_cache_get( 'root_blog_options', 'bp' ); 347 347 348 348 if ( false === $root_blog_options_meta ) { 349 349 $blog_options_keys = "'" . join( "', '", (array) $root_blog_option_keys ) . "'"; … … 426 426 unset( $root_blog_options ); 427 427 } 428 428 429 wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' );429 bp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' ); 430 430 } 431 431 432 432 return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta ); -
src/bp-friends/bp-friends-cache.php
23 23 if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) ) 24 24 return false; 25 25 26 wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' );27 wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );26 bp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' ); 27 bp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' ); 28 28 } 29 29 30 30 // List actions to clear object caches on … … 39 39 * @param int $friend_user_id The user ID not initiating the friendship 40 40 */ 41 41 function bp_friends_clear_request_cache( $friend_user_id ) { 42 wp_cache_delete( $friend_user_id, 'bp_friends_requests' );42 bp_cache_delete( $friend_user_id, 'bp_friends_requests' ); 43 43 } 44 44 45 45 /** -
src/bp-friends/bp-friends-classes.php
240 240 * @return array|bool An array of user IDs, or false if none are found. 241 241 */ 242 242 public static function get_friendship_request_user_ids( $user_id ) { 243 $friend_requests = wp_cache_get( $user_id, 'bp_friends_requests' );243 $friend_requests = bp_cache_get( $user_id, 'bp_friends_requests' ); 244 244 245 245 if ( false === $friend_requests ) { 246 246 global $wpdb, $bp; 247 247 248 248 $friend_requests = $wpdb->get_col( $wpdb->prepare( "SELECT initiator_user_id FROM {$bp->friends->table_name} WHERE friend_user_id = %d AND is_confirmed = 0", $user_id ) ); 249 249 250 wp_cache_set( $user_id, $friend_requests, 'bp_friends_requests' );250 bp_cache_set( $user_id, $friend_requests, 'bp_friends_requests' ); 251 251 } 252 252 253 253 return $friend_requests; -
src/bp-friends/bp-friends-loader.php
239 239 240 240 parent::setup_title(); 241 241 } 242 243 /** 244 * Setup cache groups 245 * 246 * @since BuddyPress (2.2.0) 247 */ 248 public function setup_cache_groups() { 249 250 // Global groups 251 wp_cache_add_global_groups( array( 252 'bp_friend_requests' 253 ) ); 254 255 parent::setup_cache_groups(); 256 } 242 257 } 243 258 244 259 /** -
src/bp-friends/bp-friends-template.php
73 73 */ 74 74 function bp_friends_random_friends() { 75 75 76 if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) {76 if ( !$friend_ids = bp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) { 77 77 $friend_ids = BP_Friends_Friendship::get_random_friends( bp_displayed_user_id() ); 78 wp_cache_set( 'friends_friend_ids_' . bp_displayed_user_id(), $friend_ids, 'bp' );78 bp_cache_set( 'friends_friend_ids_' . bp_displayed_user_id(), $friend_ids, 'bp' ); 79 79 } ?> 80 80 81 81 <div class="info-group"> … … 121 121 */ 122 122 function bp_friends_random_members( $total_members = 5 ) { 123 123 124 if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {124 if ( !$user_ids = bp_cache_get( 'friends_random_users', 'bp' ) ) { 125 125 $user_ids = BP_Core_User::get_users( 'random', $total_members ); 126 wp_cache_set( 'friends_random_users', $user_ids, 'bp' );126 bp_cache_set( 'friends_random_users', $user_ids, 'bp' ); 127 127 } 128 128 129 129 ?> … … 494 494 function bp_get_friend_friendship_id() { 495 495 global $members_template; 496 496 497 if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {497 if ( !$friendship_id = bp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { 498 498 $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() ); 499 wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );499 bp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); 500 500 } 501 501 502 502 /** … … 523 523 function bp_get_friend_accept_request_link() { 524 524 global $members_template; 525 525 526 if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {526 if ( !$friendship_id = bp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { 527 527 $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() ); 528 wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );528 bp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); 529 529 } 530 530 531 531 /** … … 552 552 function bp_get_friend_reject_request_link() { 553 553 global $members_template; 554 554 555 if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {555 if ( !$friendship_id = bp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { 556 556 $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() ); 557 wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );557 bp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); 558 558 } 559 559 560 560 /** -
src/bp-groups/bp-groups-activity.php
213 213 // rather than manually 214 214 $uncached_ids = array(); 215 215 foreach ( $group_ids as $group_id ) { 216 if ( false === wp_cache_get( $group_id, 'bp_groups' ) ) {216 if ( false === bp_cache_get( $group_id, 'bp_groups' ) ) { 217 217 $uncached_ids[] = $group_id; 218 218 } 219 219 } … … 224 224 $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) ); 225 225 $groups = $wpdb->get_results( "SELECT * FROM {$bp->groups->table_name} WHERE id IN ({$uncached_ids_sql})" ); 226 226 foreach ( $groups as $group ) { 227 wp_cache_set( $group->id, $group, 'bp_groups' );227 bp_cache_set( $group->id, $group, 'bp_groups' ); 228 228 } 229 229 } 230 230 } -
src/bp-groups/bp-groups-cache.php
48 48 * @param $group_id Not used. 49 49 */ 50 50 function groups_clear_group_object_cache( $group_id ) { 51 wp_cache_delete( 'bp_total_group_count', 'bp' );51 bp_cache_delete( 'bp_total_group_count', 'bp' ); 52 52 } 53 53 add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' ); 54 54 add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' ); … … 64 64 * @param int $group_id The group being edited. 65 65 */ 66 66 function bp_groups_delete_group_cache( $group_id = 0 ) { 67 wp_cache_delete( $group_id, 'bp_groups' );67 bp_cache_delete( $group_id, 'bp_groups' ); 68 68 } 69 69 add_action( 'groups_delete_group', 'bp_groups_delete_group_cache' ); 70 70 add_action( 'groups_update_group', 'bp_groups_delete_group_cache' ); … … 77 77 * @since BuddyPress (2.0.0) 78 78 */ 79 79 function bp_groups_delete_group_cache_on_metadata_change( $meta_id, $group_id ) { 80 wp_cache_delete( $group_id, 'bp_groups' );80 bp_cache_delete( $group_id, 'bp_groups' ); 81 81 } 82 82 add_action( 'updated_group_meta', 'bp_groups_delete_group_cache_on_metadata_change', 10, 2 ); 83 83 add_action( 'added_group_meta', 'bp_groups_delete_group_cache_on_metadata_change', 10, 2 ); … … 121 121 * @param int $user_id The user ID. 122 122 */ 123 123 function bp_groups_clear_invite_count_for_user( $user_id ) { 124 wp_cache_delete( $user_id, 'bp_group_invite_count' );124 bp_cache_delete( $user_id, 'bp_group_invite_count' ); 125 125 } 126 126 add_action( 'groups_accept_invite', 'bp_groups_clear_invite_count_for_user' ); 127 127 add_action( 'groups_reject_invite', 'bp_groups_clear_invite_count_for_user' ); … … 164 164 * @param int $user_id The user ID. 165 165 */ 166 166 function groups_clear_group_user_object_cache( $group_id, $user_id ) { 167 wp_cache_delete( 'bp_total_groups_for_user_' . $user_id, 'bp' );167 bp_cache_delete( 'bp_total_groups_for_user_' . $user_id, 'bp' ); 168 168 } 169 169 add_action( 'groups_join_group', 'groups_clear_group_user_object_cache', 10, 2 ); 170 170 add_action( 'groups_leave_group', 'groups_clear_group_user_object_cache', 10, 2 ); … … 181 181 * @param int $group_id The group ID. 182 182 */ 183 183 function groups_clear_group_administrator_cache( $group_id ) { 184 wp_cache_delete( $group_id, 'bp_group_admins' );184 bp_cache_delete( $group_id, 'bp_group_admins' ); 185 185 } 186 186 add_action( 'groups_promote_member', 'groups_clear_group_administrator_cache' ); 187 187 add_action( 'groups_demote_member', 'groups_clear_group_administrator_cache' ); -
src/bp-groups/bp-groups-classes.php
186 186 $bp = buddypress(); 187 187 188 188 // Check cache for group data 189 $group = wp_cache_get( $this->id, 'bp_groups' );189 $group = bp_cache_get( $this->id, 'bp_groups' ); 190 190 191 191 // Cache missed, so query the DB 192 192 if ( false === $group ) { 193 193 $group = $wpdb->get_row( $wpdb->prepare( "SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id = %d", $this->id ) ); 194 194 195 wp_cache_set( $this->id, $group, 'bp_groups' );195 bp_cache_set( $this->id, $group, 'bp_groups' ); 196 196 } 197 197 198 198 // No group found so set the ID and bail … … 344 344 345 345 do_action_ref_array( 'groups_group_after_save', array( &$this ) ); 346 346 347 wp_cache_delete( $this->id, 'bp_groups' );347 bp_cache_delete( $this->id, 'bp_groups' ); 348 348 349 349 return true; 350 350 } … … 372 372 373 373 do_action_ref_array( 'bp_groups_delete_group', array( &$this, $user_ids ) ); 374 374 375 wp_cache_delete( $this->id, 'bp_groups' );375 bp_cache_delete( $this->id, 'bp_groups' ); 376 376 377 377 // Finally remove the group entry from the DB 378 378 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) ) … … 2422 2422 2423 2423 $bp = buddypress(); 2424 2424 2425 $count = wp_cache_get( $user_id, 'bp_group_invite_count' );2425 $count = bp_cache_get( $user_id, 'bp_group_invite_count' ); 2426 2426 2427 2427 if ( false === $count ) { 2428 2428 $count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d", $user_id ) ); 2429 wp_cache_set( $user_id, $count, 'bp_group_invite_count' );2429 bp_cache_set( $user_id, $count, 'bp_group_invite_count' ); 2430 2430 } 2431 2431 2432 2432 return $count; … … 2630 2630 public static function get_group_administrator_ids( $group_id ) { 2631 2631 global $bp, $wpdb; 2632 2632 2633 $group_admins = wp_cache_get( $group_id, 'bp_group_admins' );2633 $group_admins = bp_cache_get( $group_id, 'bp_group_admins' ); 2634 2634 2635 2635 if ( false === $group_admins ) { 2636 2636 $group_admins = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) ); 2637 2637 2638 wp_cache_set( $group_id, $group_admins, 'bp_group_admins' );2638 bp_cache_set( $group_id, $group_admins, 'bp_group_admins' ); 2639 2639 } 2640 2640 2641 2641 return $group_admins; -
src/bp-groups/bp-groups-functions.php
644 644 * @return int 645 645 */ 646 646 function groups_get_total_group_count() { 647 $count = wp_cache_get( 'bp_total_group_count', 'bp' );647 $count = bp_cache_get( 'bp_total_group_count', 'bp' ); 648 648 649 649 if ( false === $count ) { 650 650 $count = BP_Groups_Group::get_total_group_count(); 651 wp_cache_set( 'bp_total_group_count', $count, 'bp' );651 bp_cache_set( 'bp_total_group_count', $count, 'bp' ); 652 652 } 653 653 654 654 return $count; … … 686 686 if ( empty( $user_id ) ) 687 687 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); 688 688 689 $count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' );689 $count = bp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' ); 690 690 691 691 if ( false === $count ) { 692 692 $count = BP_Groups_Member::total_group_count( $user_id ); 693 wp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, 'bp' );693 bp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, 'bp' ); 694 694 } 695 695 696 696 return $count; -
src/bp-groups/bp-groups-loader.php
676 676 677 677 parent::setup_title(); 678 678 } 679 680 /** 681 * Setup cache groups 682 * 683 * @since BuddyPress (2.2.0) 684 */ 685 public function setup_cache_groups() { 686 687 // Global groups 688 wp_cache_add_global_groups( array( 689 'bp_groups', 690 'bp_group_admins', 691 'bp_group_invite_count' 692 ) ); 693 694 parent::setup_cache_groups(); 695 } 679 696 } 680 697 681 698 /** -
src/bp-members/bp-members-cache.php
22 22 23 23 $cached_member_ids = array(); 24 24 foreach ( $member_types as $member_type ) { 25 wp_cache_set( $member_type->object_id, $member_type->name, 'bp_member_type' );25 bp_cache_set( $member_type->object_id, $member_type->name, 'bp_member_type' ); 26 26 $cached_member_ids[] = $member_type->object_id; 27 27 } 28 28 29 29 // Cache an empty value for users with no type. 30 30 foreach ( array_diff( $uncached_member_ids, $cached_member_ids ) as $no_type_id ) { 31 wp_cache_set( $no_type_id, '', 'bp_member_type' );31 bp_cache_set( $no_type_id, '', 'bp_member_type' ); 32 32 } 33 33 } 34 34 add_action( 'bp_user_query_populate_extras', 'bp_members_prefetch_member_type' ); … … 43 43 * @param int $user_id ID of the deleted user. 44 44 */ 45 45 function bp_members_clear_member_type_cache( $user_id ) { 46 wp_cache_delete( $user_id, 'bp_member_type' );46 bp_cache_delete( $user_id, 'bp_member_type' ); 47 47 } 48 48 add_action( 'wpmu_delete_user', 'bp_members_clear_member_type_cache' ); 49 49 add_action( 'delete_user', 'bp_members_clear_member_type_cache' ); -
src/bp-members/bp-members-functions.php
200 200 return false; 201 201 } 202 202 203 if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {203 if ( !$userdata = bp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) { 204 204 $userdata = BP_Core_User::get_core_userdata( $user_id ); 205 wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );205 bp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' ); 206 206 } 207 207 208 208 /** … … 296 296 $bp = buddypress(); 297 297 298 298 // Check cache for user nicename 299 $username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' );299 $username = bp_cache_get( 'bp_user_username_' . $user_id, 'bp' ); 300 300 if ( false === $username ) { 301 301 302 302 // Cache not found so prepare to update it … … 345 345 346 346 // Add this to cache 347 347 if ( ( true === $update_cache ) && !empty( $username ) ) { 348 wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );348 bp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' ); 349 349 350 350 // @todo bust this cache if no $username found? 351 351 //} else { 352 // wp_cache_delete( 'bp_user_username_' . $user_id );352 // bp_cache_delete( 'bp_user_username_' . $user_id ); 353 353 } 354 354 355 355 /** … … 378 378 function bp_members_get_user_nicename( $user_id ) { 379 379 $bp = buddypress(); 380 380 381 if ( !$user_nicename = wp_cache_get( 'bp_members_user_nicename_' . $user_id, 'bp' ) ) {381 if ( !$user_nicename = bp_cache_get( 'bp_members_user_nicename_' . $user_id, 'bp' ) ) { 382 382 $update_cache = true; 383 383 384 384 // User ID matches logged in user … … 413 413 414 414 // Add this to cache 415 415 if ( true == $update_cache && !empty( $user_nicename ) ) { 416 wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );416 bp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' ); 417 417 } 418 418 419 419 /** … … 435 435 */ 436 436 function bp_core_get_user_email( $uid ) { 437 437 438 if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {438 if ( !$email = bp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) { 439 439 440 440 // User exists 441 441 $ud = bp_core_get_core_userdata( $uid ); … … 447 447 $email = ''; 448 448 } 449 449 450 wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );450 bp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' ); 451 451 } 452 452 453 453 /** … … 529 529 530 530 $uncached_ids = array(); 531 531 foreach ( $user_ids as $user_id ) { 532 if ( false === wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {532 if ( false === bp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) { 533 533 $uncached_ids[] = $user_id; 534 534 } 535 535 } … … 576 576 } 577 577 578 578 foreach ( $fullnames as $fuser_id => $fname ) { 579 wp_cache_set( 'bp_user_fullname_' . $fuser_id, $fname, 'bp' );579 bp_cache_set( 'bp_user_fullname_' . $fuser_id, $fname, 'bp' ); 580 580 } 581 581 } 582 582 583 583 $retval = array(); 584 584 foreach ( $user_ids as $user_id ) { 585 $retval[ $user_id ] = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' );585 $retval[ $user_id ] = bp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ); 586 586 } 587 587 588 588 return $retval; … … 691 691 function bp_core_get_total_member_count() { 692 692 global $wpdb; 693 693 694 $count = wp_cache_get( 'bp_total_member_count', 'bp' );694 $count = bp_cache_get( 'bp_total_member_count', 'bp' ); 695 695 696 696 if ( false === $count ) { 697 697 $status_sql = bp_core_get_status_sql(); 698 698 $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}" ); 699 wp_cache_set( 'bp_total_member_count', $count, 'bp' );699 bp_cache_set( 'bp_total_member_count', $count, 'bp' ); 700 700 } 701 701 702 702 /** … … 2592 2592 2593 2593 // Bust the cache if the type has been updated. 2594 2594 if ( ! is_wp_error( $retval ) ) { 2595 wp_cache_delete( $user_id, 'bp_member_type' );2595 bp_cache_delete( $user_id, 'bp_member_type' ); 2596 2596 2597 2597 /** 2598 2598 * Fires just after a user's member type has been changed. … … 2621 2621 * types (if $single is false). Returns false on failure. 2622 2622 */ 2623 2623 function bp_get_member_type( $user_id, $single = true ) { 2624 $types = wp_cache_get( $user_id, 'bp_member_type' );2624 $types = bp_cache_get( $user_id, 'bp_member_type' ); 2625 2625 2626 2626 if ( false === $types ) { 2627 2627 $types = bp_get_object_terms( $user_id, 'bp_member_type' ); 2628 2628 2629 2629 if ( ! is_wp_error( $types ) ) { 2630 2630 $types = wp_list_pluck( $types, 'name' ); 2631 wp_cache_set( $user_id, $types, 'bp_member_type' );2631 bp_cache_set( $user_id, $types, 'bp_member_type' ); 2632 2632 } 2633 2633 } 2634 2634 -
src/bp-members/bp-members-loader.php
276 276 277 277 parent::setup_title(); 278 278 } 279 280 /** 281 * Setup cache groups 282 * 283 * @since BuddyPress (2.2.0) 284 */ 285 public function setup_cache_groups() { 286 287 // Global groups 288 wp_cache_add_global_groups( array( 289 'bp_member_type' 290 ) ); 291 292 parent::setup_cache_groups(); 293 } 279 294 } 280 295 281 296 /** -
src/bp-messages/bp-messages-cache.php
54 54 */ 55 55 function bp_messages_clear_unread_count_cache_on_message_save( BP_Messages_Message $message ) { 56 56 foreach ( (array) $message->recipients as $recipient ) { 57 wp_cache_delete( $recipient->user_id, 'bp_messages_unread_count' );57 bp_cache_delete( $recipient->user_id, 'bp_messages_unread_count' ); 58 58 } 59 59 } 60 60 add_action( 'messages_message_after_save', 'bp_messages_clear_unread_count_cache_on_message_save' ); … … 68 68 * array of thread IDs 69 69 */ 70 70 function bp_messages_clear_unread_count_cache_on_message_delete( $thread_ids ) { 71 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' );71 bp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); 72 72 } 73 73 add_action( 'messages_before_delete_thread', 'bp_messages_clear_unread_count_cache_on_message_delete' ); 74 74 … … 80 80 * @since BuddyPress (2.0.0) 81 81 */ 82 82 function bp_notices_clear_cache( $notice ) { 83 wp_cache_delete( 'active_notice', 'bp_messages' );83 bp_cache_delete( 'active_notice', 'bp_messages' ); 84 84 } 85 85 add_action( 'messages_notice_after_save', 'bp_notices_clear_cache' ); 86 86 add_action( 'messages_notice_before_delete', 'bp_notices_clear_cache' ); -
src/bp-messages/bp-messages-classes.php
434 434 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ); 435 435 $wpdb->query($sql); 436 436 437 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' );437 bp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); 438 438 } 439 439 440 440 /** … … 450 450 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ); 451 451 $wpdb->query($sql); 452 452 453 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' );453 bp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); 454 454 } 455 455 456 456 /** … … 533 533 $user_id = bp_loggedin_user_id(); 534 534 } 535 535 536 $unread_count = wp_cache_get( $user_id, 'bp_messages_unread_count' );536 $unread_count = bp_cache_get( $user_id, 'bp_messages_unread_count' ); 537 537 538 538 if ( false === $unread_count ) { 539 539 $unread_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM(unread_count) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0 AND sender_only = 0", $user_id ) ); 540 540 541 wp_cache_set( $user_id, $unread_count, 'bp_messages_unread_count' );541 bp_cache_set( $user_id, $unread_count, 'bp_messages_unread_count' ); 542 542 } 543 543 544 544 /** … … 1132 1132 * @return object The BP_Messages_Notice object 1133 1133 */ 1134 1134 public static function get_active() { 1135 $notice = wp_cache_get( 'active_notice', 'bp_messages' );1135 $notice = bp_cache_get( 'active_notice', 'bp_messages' ); 1136 1136 1137 1137 if ( false === $notice ) { 1138 1138 global $wpdb, $bp; … … 1140 1140 $notice_id = $wpdb->get_var( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1" ); 1141 1141 $notice = new BP_Messages_Notice( $notice_id ); 1142 1142 1143 wp_cache_set( 'active_notice', $notice, 'bp_messages' );1143 bp_cache_set( 'active_notice', $notice, 'bp_messages' ); 1144 1144 } 1145 1145 1146 1146 return $notice; -
src/bp-messages/bp-messages-loader.php
292 292 293 293 parent::setup_title(); 294 294 } 295 296 /** 297 * Setup cache groups 298 * 299 * @since BuddyPress (2.2.0) 300 */ 301 public function setup_cache_groups() { 302 303 // Global groups 304 wp_cache_add_global_groups( array( 305 'bp_messages', 306 'bp_messages_unread_count', 307 'message_meta' 308 ) ); 309 310 parent::setup_cache_groups(); 311 } 295 312 } 296 313 297 314 /** -
src/bp-notifications/bp-notifications-cache.php
14 14 * @param BP_Notification_Notification $n Notification object. 15 15 */ 16 16 function bp_notifications_clear_all_for_user_cache_after_save( BP_Notifications_Notification $n ) { 17 wp_cache_delete( 'all_for_user_' . $n->user_id, 'bp_notifications' );17 bp_cache_delete( 'all_for_user_' . $n->user_id, 'bp_notifications' ); 18 18 } 19 19 add_action( 'bp_notification_after_save', 'bp_notifications_clear_all_for_user_cache_after_save' ); 20 20 … … 35 35 } 36 36 37 37 foreach ( array_unique( $user_ids ) as $user_id ) { 38 wp_cache_delete( 'all_for_user_' . $user_id, 'bp_notifications' );38 bp_cache_delete( 'all_for_user_' . $user_id, 'bp_notifications' ); 39 39 } 40 40 } 41 41 add_action( 'bp_notification_before_delete', 'bp_notifications_clear_all_for_user_cache_before_delete' ); -
src/bp-notifications/bp-notifications-classes.php
681 681 682 682 // make sure we delete the notification cache for the user on update 683 683 if ( ! empty( $where_args['user_id'] ) ) { 684 wp_cache_delete( 'all_for_user_' . $where_args['user_id'], 'bp_notifications' );684 bp_cache_delete( 'all_for_user_' . $where_args['user_id'], 'bp_notifications' ); 685 685 } 686 686 687 687 return self::_update( $update['data'], $where['data'], $update['format'], $where['format'] ); -
src/bp-notifications/bp-notifications-functions.php
143 143 } 144 144 145 145 // Get notifications out of the cache, or query if necessary 146 $notifications = wp_cache_get( 'all_for_user_' . $user_id, 'bp_notifications' );146 $notifications = bp_cache_get( 'all_for_user_' . $user_id, 'bp_notifications' ); 147 147 if ( false === $notifications ) { 148 148 $notifications = BP_Notifications_Notification::get( array( 149 149 'user_id' => $user_id 150 150 ) ); 151 wp_cache_set( 'all_for_user_' . $user_id, $notifications, 'bp_notifications' );151 bp_cache_set( 'all_for_user_' . $user_id, $notifications, 'bp_notifications' ); 152 152 } 153 153 154 154 // Filter and return -
src/bp-notifications/bp-notifications-loader.php
237 237 238 238 parent::setup_title(); 239 239 } 240 241 /** 242 * Setup cache groups 243 * 244 * @since BuddyPress (2.2.0) 245 */ 246 public function setup_cache_groups() { 247 248 // Global groups 249 wp_cache_add_global_groups( array( 250 'bp_notifications' 251 ) ); 252 253 parent::setup_cache_groups(); 254 } 240 255 } 241 256 242 257 /** -
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' );199 bp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' ); 200 200 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); 201 201 } 202 202 … … 468 468 469 469 if ( $email_changed ) { 470 470 // Delete object cache for displayed user 471 wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' );471 bp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' ); 472 472 473 473 // Delete the pending email change key 474 474 bp_delete_user_meta( bp_displayed_user_id(), 'pending_email_change' ); -
src/bp-xprofile/bp-xprofile-cache.php
13 13 if ( !defined( 'ABSPATH' ) ) exit; 14 14 15 15 /** 16 * Determine which xprofile fields do not have cached values for a user. 17 * 18 * @since BuddyPress (2.2.0) 19 * 20 * @param int $user_id User ID to check 21 * @param array $field_ids XProfile field IDs. 22 * @return array 23 */ 24 function bp_xprofile_get_non_cached_field_ids( $user_id = 0, $field_ids = array() ) { 25 $uncached_fields = array(); 26 27 foreach ( $field_ids as $field_id ) { 28 $field_id = (int) $field_id; 29 $cache_key = "{$user_id}:{$field_id}"; 30 if ( false === bp_cache_get( $cache_key, 'bp_xprofile_data' ) ) { 31 $uncached_fields[] = $field_id; 32 } 33 } 34 35 return $uncached_fields; 36 } 37 38 /** 16 39 * Slurp up xprofilemeta for a specified set of profile objects. 17 40 * 18 41 * We do not use bp_update_meta_cache() for the xprofile component. This is … … 112 135 foreach ( $cache as $object_type => $object_caches ) { 113 136 $cache_group = $cache_groups[ $object_type ]; 114 137 foreach ( $object_caches as $object_id => $object_cache ) { 115 wp_cache_set( $object_id, $object_cache, $cache_group );138 bp_cache_set( $object_id, $object_cache, $cache_group ); 116 139 } 117 140 } 118 141 } … … 121 144 } 122 145 123 146 function xprofile_clear_profile_groups_object_cache( $group_obj ) { 124 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );125 wp_cache_delete( 'xprofile_group_' . $group_obj->id, 'bp' );147 bp_cache_delete( 'xprofile_groups_inc_empty', 'bp' ); 148 bp_cache_delete( 'xprofile_group_' . $group_obj->id, 'bp' ); 126 149 } 127 150 add_action( 'xprofile_group_after_delete', 'xprofile_clear_profile_groups_object_cache' ); 128 151 add_action( 'xprofile_group_after_save', 'xprofile_clear_profile_groups_object_cache' ); 129 152 130 153 function xprofile_clear_profile_data_object_cache( $group_id ) { 131 wp_cache_delete( 'bp_user_fullname_' . bp_loggedin_user_id(), 'bp' );154 bp_cache_delete( 'bp_user_fullname_' . bp_loggedin_user_id(), 'bp' ); 132 155 } 133 156 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 134 157 … … 142 165 */ 143 166 function xprofile_clear_fullname_cache_on_profile_field_edit( $data ) { 144 167 if ( 1 == $data->field_id ) { 145 wp_cache_delete( 'bp_user_fullname_' . $data->user_id, 'bp' );168 bp_cache_delete( 'bp_user_fullname_' . $data->user_id, 'bp' ); 146 169 } 147 170 } 148 171 add_action( 'xprofile_data_after_save', 'xprofile_clear_fullname_cache_on_profile_field_edit' ); … … 156 179 */ 157 180 function xprofile_clear_profile_field_object_cache( $field_obj ) { 158 181 // Clear default visibility level cache 159 wp_cache_delete( 'xprofile_default_visibility_levels', 'bp' );182 bp_cache_delete( 'xprofile_default_visibility_levels', 'bp' ); 160 183 161 184 // Modified fields can alter parent group status, in particular when 162 185 // the group goes from empty to non-empty. Bust its cache, as well as 163 186 // the global group_inc_empty cache 164 wp_cache_delete( 'xprofile_group_' . $field_obj->group_id, 'bp' );165 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );187 bp_cache_delete( 'xprofile_group_' . $field_obj->group_id, 'bp' ); 188 bp_cache_delete( 'xprofile_groups_inc_empty', 'bp' ); 166 189 } 167 190 add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' ); 168 191 add_action( 'xprofile_fields_deleted_field', 'xprofile_clear_profile_field_object_cache' ); … … 175 198 * @param BP_XProfile_ProfileData $data_obj 176 199 */ 177 200 function xprofile_clear_profiledata_object_cache( $data_obj ) { 178 wp_cache_delete( $data_obj->field_id, 'bp_xprofile_data_' . $data_obj->user_id);201 bp_cache_delete( "{$data_obj->user_id}:{$data_obj->field_id}", 'bp_xprofile_data' ); 179 202 } 180 203 add_action( 'xprofile_data_after_save', 'xprofile_clear_profiledata_object_cache' ); 181 204 add_action( 'xprofile_data_after_delete', 'xprofile_clear_profiledata_object_cache' ); … … 196 219 * @since BuddyPress (2.0.0) 197 220 */ 198 221 function xprofile_clear_fullname_field_id_cache() { 199 wp_cache_delete( 'fullname_field_id', 'bp_xprofile' );222 bp_cache_delete( 'fullname_field_id', 'bp_xprofile' ); 200 223 } 201 224 add_action( 'update_option_bp-xprofile-fullname-field-name', 'xprofile_clear_fullname_field_id_cache' ); 202 225 -
src/bp-xprofile/bp-xprofile-classes.php
26 26 public function populate( $id ) { 27 27 global $wpdb, $bp; 28 28 29 $group = wp_cache_get( 'xprofile_group_' . $this->id, 'bp' );29 $group = bp_cache_get( 'xprofile_group_' . $this->id, 'bp' ); 30 30 31 31 if ( false === $group ) { 32 32 $group = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id ) ); … … 367 367 foreach ( $group_ids as $group_id ) { 368 368 369 369 // If cached data is found, use it 370 if ( $group_data = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {370 if ( $group_data = bp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) { 371 371 $groups[ $group_id ] = $group_data; 372 372 373 373 // Otherwise leave a placeholder so we don't lose the order … … 392 392 // and add it to the cache 393 393 foreach ( (array) $queried_gdata as $gdata ) { 394 394 $groups[ $gdata->id ] = $gdata; 395 wp_cache_set( 'xprofile_group_' . $gdata->id, $gdata, 'bp' );395 bp_cache_set( 'xprofile_group_' . $gdata->id, $gdata, 'bp' ); 396 396 } 397 397 } 398 398 … … 422 422 } 423 423 424 424 // purge profile field group cache 425 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );425 bp_cache_delete( 'xprofile_groups_inc_empty', 'bp' ); 426 426 427 427 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET group_order = %d WHERE id = %d", $position, $field_group_id ) ); 428 428 } … … 482 482 public static function fetch_default_visibility_levels() { 483 483 global $wpdb, $bp; 484 484 485 $default_visibility_levels = wp_cache_get( 'xprofile_default_visibility_levels', 'bp' );485 $default_visibility_levels = bp_cache_get( 'xprofile_default_visibility_levels', 'bp' ); 486 486 487 487 if ( false === $default_visibility_levels ) { 488 488 $levels = $wpdb->get_results( "SELECT object_id, meta_key, meta_value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND ( meta_key = 'default_visibility' OR meta_key = 'allow_custom_visibility' )" ); … … 497 497 } 498 498 } 499 499 500 wp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, 'bp' );500 bp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, 'bp' ); 501 501 } 502 502 503 503 return $default_visibility_levels; … … 1222 1222 public function populate( $field_id, $user_id ) { 1223 1223 global $wpdb, $bp; 1224 1224 1225 $cache_ group = 'bp_xprofile_data_' . $user_id;1226 $profiledata = wp_cache_get( $field_id, $cache_group);1225 $cache_key = "{$user_id}:{$field_id}"; 1226 $profiledata = bp_cache_get( $cache_key, 'bp_xprofile_data' ); 1227 1227 1228 1228 if ( false === $profiledata ) { 1229 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id );1229 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ); 1230 1230 $profiledata = $wpdb->get_row( $sql ); 1231 1231 1232 1232 if ( $profiledata ) { 1233 wp_cache_set( $field_id, $profiledata, $cache_group);1233 bp_cache_set( $cache_key, $profiledata, 'bp_xprofile_data' ); 1234 1234 } 1235 1235 } 1236 1236 … … 1259 1259 global $wpdb, $bp; 1260 1260 1261 1261 // Check cache first 1262 $cached = wp_cache_get( $this->field_id, 'bp_xprofile_data_' . $this->user_id ); 1262 $cache_key = "{$this->user_id}:{$this->field_id}"; 1263 $cached = bp_cache_get( $cache_key, 'bp_xprofile_data' ); 1263 1264 1264 1265 if ( $cached && ! empty( $cached->id ) ) { 1265 1266 $retval = true; … … 1400 1401 1401 1402 $data = array(); 1402 1403 1403 $ cache_group = 'bp_xprofile_data_' . $user_id;1404 $uncached_field_ids = bp_xprofile_get_non_cached_field_ids( $user_id, $field_ids, 'bp_xprofile_data' ); 1404 1405 1405 $uncached_field_ids = bp_get_non_cached_ids( $field_ids, $cache_group );1406 1407 1406 // Prime the cache 1408 1407 if ( ! empty( $uncached_field_ids ) ) { 1409 1408 $bp = buddypress(); … … 1426 1425 // Set caches 1427 1426 foreach ( $uncached_field_ids as $field_id ) { 1428 1427 1428 $cache_key = "{$user_id}:{$field_id}"; 1429 1429 1430 // If a value was found, cache it 1430 1431 if ( isset( $queried_data[ $field_id ] ) ) { 1431 wp_cache_set( $field_id, $queried_data[ $field_id ], $cache_group);1432 bp_cache_set( $cache_key, $queried_data[ $field_id ], 'bp_xprofile_data' ); 1432 1433 1433 1434 // If no value was found, cache an empty item 1434 1435 // to avoid future cache misses … … 1440 1441 $d->value = ''; 1441 1442 $d->last_updated = ''; 1442 1443 1443 wp_cache_set( $field_id, $d, $cache_group);1444 bp_cache_set( $cache_key, $d, 'bp_xprofile_data' ); 1444 1445 } 1445 1446 } 1446 1447 } 1447 1448 1448 1449 // Now that all items are cached, fetch them 1449 1450 foreach ( $field_ids as $field_id ) { 1450 $data[] = wp_cache_get( $field_id, $cache_group ); 1451 $cache_key = "{$user_id}:{$field_id}"; 1452 $data[] = bp_cache_get( $cache_key, 'bp_xprofile_data' ); 1451 1453 } 1452 1454 1453 1455 return $data; … … 1460 1462 * @return array 1461 1463 */ 1462 1464 public static function get_all_for_user( $user_id ) { 1463 global $wpdb, $bp;1464 1465 1465 1466 $groups = bp_xprofile_get_groups( array( 1466 1467 'user_id' => $user_id, … … 1514 1515 } else { 1515 1516 1516 1517 // Check cache first 1517 $fielddata = wp_cache_get( $field_id, 'bp_xprofile_data_' . $user_id ); 1518 $cache_key = "{$user_id}:{$field_id}"; 1519 $fielddata = bp_cache_get( $cache_key, 'bp_xprofile_data' ); 1518 1520 if ( false === $fielddata || empty( $fielddata->id ) ) { 1519 1521 $fielddata_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ) ); 1520 1522 } else { … … 1551 1553 // Assemble uncached IDs 1552 1554 $uncached_ids = array(); 1553 1555 foreach ( $user_ids as $user_id ) { 1554 if ( false === wp_cache_get( $field_id, 'bp_xprofile_data_' . $user_id ) ) { 1556 $cache_key = "{$user_id}:{$field_id}"; 1557 if ( false === bp_cache_get( $cache_key, 'bp_xprofile_data' ) ) { 1555 1558 $uncached_ids[] = $user_id; 1556 1559 } 1557 1560 } … … 1583 1586 $d->last_updated = ''; 1584 1587 } 1585 1588 1586 wp_cache_set( $field_id, $d, 'bp_xprofile_data_' . $d->user_id ); 1589 $cache_key = "{$d->user_id}:{$field_id}"; 1590 bp_cache_set( $cache_key, $d, 'bp_xprofile_data' ); 1587 1591 } 1588 1592 } 1589 1593 1590 1594 // Now that the cache is primed with all data, fetch it 1591 1595 $data = array(); 1592 1596 foreach ( $user_ids as $user_id ) { 1593 $data[] = wp_cache_get( $field_id, 'bp_xprofile_data_' . $user_id ); 1597 $cache_key = "{$user_id}:{$field_id}"; 1598 $data[] = bp_cache_get( $cache_key, 'bp_xprofile_data' ); 1594 1599 } 1595 1600 1596 1601 // If a single ID was passed, just return the value -
src/bp-xprofile/bp-xprofile-functions.php
981 981 * @return int Field ID. 982 982 */ 983 983 function bp_xprofile_fullname_field_id() { 984 $id = wp_cache_get( 'fullname_field_id', 'bp_xprofile' );984 $id = bp_cache_get( 'fullname_field_id', 'bp_xprofile' ); 985 985 986 986 if ( false === $id ) { 987 987 global $wpdb; … … 989 989 $bp = buddypress(); 990 990 $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 991 991 992 wp_cache_set( 'fullname_field_id', $id, 'bp_xprofile' );992 bp_cache_set( 'fullname_field_id', $id, 'bp_xprofile' ); 993 993 } 994 994 995 995 return absint( $id ); -
src/bp-xprofile/bp-xprofile-loader.php
353 353 } 354 354 355 355 /** 356 * Setup cache groups 357 * 358 * @since BuddyPress (2.2.0) 359 */ 360 public function setup_cache_groups() { 361 362 // Global groups 363 wp_cache_add_global_groups( array( 364 'bp_xprofile', 365 'bp_xprofile_data', 366 'xprofile_meta' 367 ) ); 368 369 parent::setup_cache_groups(); 370 } 371 372 /** 356 373 * Adds "Settings > Profile" subnav item under the "Settings" adminbar menu. 357 374 * 358 375 * @since BuddyPress (2.0.0) -
src/bp-xprofile/bp-xprofile-template.php
801 801 * @return object $groups 802 802 */ 803 803 function bp_profile_get_field_groups() { 804 $groups = wp_cache_get( 'xprofile_groups_inc_empty', 'bp' );804 $groups = bp_cache_get( 'xprofile_groups_inc_empty', 'bp' ); 805 805 806 806 if ( empty( $groups ) ) { 807 807 $groups = bp_xprofile_get_groups( array( 'fetch_fields' => true ) ); 808 wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );808 bp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' ); 809 809 } 810 810 811 811 /** … … 899 899 if ( !is_numeric( $group_id ) ) 900 900 $group_id = 1; 901 901 902 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {902 if ( !$group = bp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) { 903 903 $group = new BP_XProfile_Group($group_id); 904 wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' );904 bp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' ); 905 905 } 906 906 907 907 /** -
tests/phpunit/testcases/activity/cache.php
23 23 bp_activity_get_meta( $a1, 'foo' ); 24 24 25 25 // Ensure an empty cache for $a2 26 wp_cache_delete( $a2, 'activity_meta' );26 bp_cache_delete( $a2, 'activity_meta' ); 27 27 28 28 bp_activity_update_meta_cache( array( $a1, $a2 ) ); 29 29 … … 47 47 ); 48 48 49 49 $found = array( 50 $a1 => wp_cache_get( $a1, 'activity_meta' ),51 $a2 => wp_cache_get( $a2, 'activity_meta' ),50 $a1 => bp_cache_get( $a1, 'activity_meta' ), 51 $a2 => bp_cache_get( $a2, 'activity_meta' ), 52 52 ); 53 53 54 54 $this->assertEquals( $expected, $found ); -
tests/phpunit/testcases/activity/functions.php
305 305 $a = $this->factory->activity->create(); 306 306 bp_activity_add_meta( $a, 'foo', 'bar' ); 307 307 bp_activity_add_meta( $a, 'foo1', 'baz' ); 308 $this->assertFalse( wp_cache_get( $a, 'activity_meta' ) );308 $this->assertFalse( bp_cache_get( $a, 'activity_meta' ) ); 309 309 310 310 // A single query should prime the whole meta cache 311 311 bp_activity_get_meta( $a, 'foo' ); 312 312 313 $c = wp_cache_get( $a, 'activity_meta' );313 $c = bp_cache_get( $a, 'activity_meta' ); 314 314 $this->assertNotEmpty( $c['foo1'] ); 315 315 } 316 316 … … 947 947 ) ); 948 948 949 949 // should be populated 950 $this->assertNotEmpty( wp_cache_get( $a1, 'bp_activity_comments' ) );950 $this->assertNotEmpty( bp_cache_get( $a1, 'bp_activity_comments' ) ); 951 951 952 952 bp_activity_new_comment( array( 953 953 'activity_id' => $a1, … … 957 957 ) ); 958 958 959 959 // should be empty 960 $this->assertFalse( wp_cache_get( $a1, 'bp_activity_comments' ) );960 $this->assertFalse( bp_cache_get( $a1, 'bp_activity_comments' ) ); 961 961 } 962 962 963 963 /** … … 998 998 ) ); 999 999 1000 1000 // should be populated 1001 $this->assertNotEmpty( wp_cache_get( $a1, 'bp_activity' ) );1002 $this->assertNotEmpty( wp_cache_get( $a2, 'bp_activity' ) );1003 $this->assertNotEmpty( wp_cache_get( $a3, 'bp_activity' ) );1004 $this->assertNotEmpty( wp_cache_get( $a4, 'bp_activity' ) );1005 $this->assertNotEmpty( wp_cache_get( $a5, 'bp_activity' ) );1001 $this->assertNotEmpty( bp_cache_get( $a1, 'bp_activity' ) ); 1002 $this->assertNotEmpty( bp_cache_get( $a2, 'bp_activity' ) ); 1003 $this->assertNotEmpty( bp_cache_get( $a3, 'bp_activity' ) ); 1004 $this->assertNotEmpty( bp_cache_get( $a4, 'bp_activity' ) ); 1005 $this->assertNotEmpty( bp_cache_get( $a5, 'bp_activity' ) ); 1006 1006 1007 1007 // Stuff may run on bp_activity_comment_posted that loads the 1008 1008 // cache, so we use this dumb technique to check cache values … … 1053 1053 bp_activity_delete_comment( $a1, $a2 ); 1054 1054 1055 1055 // assert comment cache as empty for $a1 1056 $this->assertEmpty( wp_cache_get( $a1, 'bp_activity_comments' ) );1056 $this->assertEmpty( bp_cache_get( $a1, 'bp_activity_comments' ) ); 1057 1057 } 1058 1058 1059 1059 /** … … 1190 1190 1191 1191 public function check_activity_caches() { 1192 1192 foreach ( $this->acaches as $k => $v ) { 1193 $this->acaches[ $k ] = wp_cache_get( $k, 'bp_activity' );1193 $this->acaches[ $k ] = bp_cache_get( $k, 'bp_activity' ); 1194 1194 } 1195 1195 } 1196 1196 } -
tests/phpunit/testcases/activity/template.php
886 886 'update_meta_cache' => false, 887 887 ) ); 888 888 889 $this->assertFalse( wp_cache_get( $a1, 'activity_meta' ) );890 $this->assertFalse( wp_cache_get( $a2, 'activity_meta' ) );889 $this->assertFalse( bp_cache_get( $a1, 'activity_meta' ) ); 890 $this->assertFalse( bp_cache_get( $a2, 'activity_meta' ) ); 891 891 } 892 892 893 893 /** … … 913 913 'update_meta_cache' => true, 914 914 ) ); 915 915 916 $this->assertNotEmpty( wp_cache_get( $a1, 'activity_meta' ) );917 $this->assertNotEmpty( wp_cache_get( $a2, 'activity_meta' ) );916 $this->assertNotEmpty( bp_cache_get( $a1, 'activity_meta' ) ); 917 $this->assertNotEmpty( bp_cache_get( $a2, 'activity_meta' ) ); 918 918 } 919 919 920 920 /** -
tests/phpunit/testcases/blogs/cache.php
30 30 $b2_last_activity = bp_blogs_get_blogmeta( $b2, 'last_activity' ); 31 31 32 32 // Clear caches (due to _get_) 33 wp_cache_delete( $b1, 'blog_meta' );34 wp_cache_delete( $b2, 'blog_meta' );33 bp_cache_delete( $b1, 'blog_meta' ); 34 bp_cache_delete( $b2, 'blog_meta' ); 35 35 36 36 // Caches should be empty 37 $this->assertFalse( wp_cache_get( $b1, 'blog_meta' ) );38 $this->assertFalse( wp_cache_get( $b2, 'blog_meta' ) );37 $this->assertFalse( bp_cache_get( $b1, 'blog_meta' ) ); 38 $this->assertFalse( bp_cache_get( $b2, 'blog_meta' ) ); 39 39 40 40 bp_blogs_update_meta_cache( array( $b1, $b2 ) ); 41 41 … … 74 74 75 75 // The cache may contain more than just this, so loop through 76 76 // and check only relevant keys 77 $b1_found = wp_cache_get( $b1, 'blog_meta' );77 $b1_found = bp_cache_get( $b1, 'blog_meta' ); 78 78 foreach ( $b1_expected as $k => $v ) { 79 79 $this->assertSame( $v, $b1_found[ $k ] ); 80 80 } 81 81 82 $b2_found = wp_cache_get( $b2, 'blog_meta' );82 $b2_found = bp_cache_get( $b2, 'blog_meta' ); 83 83 foreach ( $b2_expected as $k => $v ) { 84 84 $this->assertSame( $v, $b2_found[ $k ] ); 85 85 } … … 120 120 $b2_last_activity = bp_blogs_get_blogmeta( $b2, 'last_activity' ); 121 121 122 122 // Clear caches (due to _get_) 123 wp_cache_delete( $b1, 'blog_meta' );124 wp_cache_delete( $b2, 'blog_meta' );123 bp_cache_delete( $b1, 'blog_meta' ); 124 bp_cache_delete( $b2, 'blog_meta' ); 125 125 126 126 // Caches should be empty 127 $this->assertFalse( wp_cache_get( $b1, 'blog_meta' ) );128 $this->assertFalse( wp_cache_get( $b2, 'blog_meta' ) );127 $this->assertFalse( bp_cache_get( $b1, 'blog_meta' ) ); 128 $this->assertFalse( bp_cache_get( $b2, 'blog_meta' ) ); 129 129 130 130 bp_has_blogs( array( 131 131 'user_id' => $u, … … 166 166 167 167 // The cache may contain more than just this, so loop through 168 168 // and check only relevant keys 169 $b1_found = wp_cache_get( $b1, 'blog_meta' );169 $b1_found = bp_cache_get( $b1, 'blog_meta' ); 170 170 foreach ( $b1_expected as $k => $v ) { 171 171 $this->assertSame( $v, $b1_found[ $k ] ); 172 172 } 173 173 174 $b2_found = wp_cache_get( $b2, 'blog_meta' );174 $b2_found = bp_cache_get( $b2, 'blog_meta' ); 175 175 foreach ( $b2_expected as $k => $v ) { 176 176 $this->assertSame( $v, $b2_found[ $k ] ); 177 177 } … … 214 214 $b2_last_activity = bp_blogs_get_blogmeta( $b2, 'last_activity' ); 215 215 216 216 // Clear caches (due to _get_) 217 wp_cache_delete( $b1, 'blog_meta' );218 wp_cache_delete( $b2, 'blog_meta' );217 bp_cache_delete( $b1, 'blog_meta' ); 218 bp_cache_delete( $b2, 'blog_meta' ); 219 219 220 220 // Caches should be empty 221 $this->assertFalse( wp_cache_get( $b1, 'blog_meta' ) );222 $this->assertFalse( wp_cache_get( $b2, 'blog_meta' ) );221 $this->assertFalse( bp_cache_get( $b1, 'blog_meta' ) ); 222 $this->assertFalse( bp_cache_get( $b2, 'blog_meta' ) ); 223 223 224 224 bp_has_blogs( array( 225 225 'update_meta_cache' => false, 226 226 ) ); 227 227 228 228 // Caches should be empty 229 $this->assertFalse( wp_cache_get( $b1, 'blog_meta' ) );230 $this->assertFalse( wp_cache_get( $b2, 'blog_meta' ) );229 $this->assertFalse( bp_cache_get( $b1, 'blog_meta' ) ); 230 $this->assertFalse( bp_cache_get( $b2, 'blog_meta' ) ); 231 231 232 232 $this->set_current_user( $old_user ); 233 233 } -
tests/phpunit/testcases/core/cache.php
24 24 'object_column' => 'activity_id', 25 25 ) ); 26 26 27 $this->assertSame( array(), wp_cache_get( $a1, 'activity_meta' ) );27 $this->assertSame( array(), bp_cache_get( $a1, 'activity_meta' ) ); 28 28 } 29 29 } 30 30 -
tests/phpunit/testcases/core/class-bp-core-user.php
200 200 201 201 // Cache is set during user creation. Clear to reflect actual 202 202 // pageload 203 wp_cache_delete( $u, 'bp_last_activity' );203 bp_cache_delete( $u, 'bp_last_activity' ); 204 204 205 205 // prime cache 206 206 $a = BP_Core_User::get_last_activity( $u ); 207 207 208 $this->assertSame( $a[ $u ], wp_cache_get( $u, 'bp_last_activity' ) );208 $this->assertSame( $a[ $u ], bp_cache_get( $u, 'bp_last_activity' ) ); 209 209 } 210 210 211 211 /** … … 219 219 220 220 // Cache is set during user creation. Clear to reflect actual 221 221 // pageload 222 wp_cache_delete( $u1, 'bp_last_activity' );223 wp_cache_delete( $u2, 'bp_last_activity' );222 bp_cache_delete( $u1, 'bp_last_activity' ); 223 bp_cache_delete( $u2, 'bp_last_activity' ); 224 224 225 225 // prime cache 226 226 $a = BP_Core_User::get_last_activity( array( $u1, $u2 ) ); 227 227 228 $this->assertSame( $a[ $u1 ], wp_cache_get( $u1, 'bp_last_activity' ) );229 $this->assertSame( $a[ $u2 ], wp_cache_get( $u2, 'bp_last_activity' ) );228 $this->assertSame( $a[ $u1 ], bp_cache_get( $u1, 'bp_last_activity' ) ); 229 $this->assertSame( $a[ $u2 ], bp_cache_get( $u2, 'bp_last_activity' ) ); 230 230 } 231 231 232 232 /** … … 241 241 242 242 // Cache is set during user creation. Clear to reflect actual 243 243 // pageload 244 wp_cache_delete( $u, 'bp_last_activity' );244 bp_cache_delete( $u, 'bp_last_activity' ); 245 245 246 246 // Prime cache 247 247 $uncached = BP_Core_User::get_last_activity( $u ); … … 265 265 BP_Core_User::update_last_activity( $u2, $time ); 266 266 267 267 // Cache is set during user creation. Clear to reflect actual pageload 268 wp_cache_delete( $u1, 'bp_last_activity' );269 wp_cache_delete( $u2, 'bp_last_activity' );268 bp_cache_delete( $u1, 'bp_last_activity' ); 269 bp_cache_delete( $u2, 'bp_last_activity' ); 270 270 271 271 // Prime cache 272 272 $uncached = BP_Core_User::get_last_activity( array( $u1, $u2 ) ); 273 273 274 274 // Second grab will be from the cache 275 275 $cached = BP_Core_User::get_last_activity( array( $u1, $u2 ) ); 276 $cached_u1 = wp_cache_get( $u1, 'bp_last_activity' );276 $cached_u1 = bp_cache_get( $u1, 'bp_last_activity' ); 277 277 278 278 $this->assertSame( $cached, $uncached ); 279 279 } -
tests/phpunit/testcases/core/class-bp-user-query.php
514 514 'include' => $users, 515 515 ) ); 516 516 517 $this->assertSame( 'foo', wp_cache_get( $users[0], 'bp_member_type' ) );518 $this->assertSame( 'bar', wp_cache_get( $users[1], 'bp_member_type' ) );519 $this->assertSame( 'foo', wp_cache_get( $users[2], 'bp_member_type' ) );520 $this->assertSame( '', wp_cache_get( $users[3], 'bp_member_type' ) );517 $this->assertSame( 'foo', bp_cache_get( $users[0], 'bp_member_type' ) ); 518 $this->assertSame( 'bar', bp_cache_get( $users[1], 'bp_member_type' ) ); 519 $this->assertSame( 'foo', bp_cache_get( $users[2], 'bp_member_type' ) ); 520 $this->assertSame( '', bp_cache_get( $users[3], 'bp_member_type' ) ); 521 521 } 522 522 } -
tests/phpunit/testcases/core/functions.php
416 416 417 417 restore_current_blog(); 418 418 419 $this->assertFalse( wp_cache_get( 'directory_pages', 'bp' ) );419 $this->assertFalse( bp_cache_get( 'directory_pages', 'bp' ) ); 420 420 } 421 421 422 422 /** … … 556 556 $v = bp_get_option( 'bp-pages' ); 557 557 bp_update_option( 'bp-pages', 'foo' ); 558 558 559 $this->assertFalse( wp_cache_get( 'directory_pages', 'bp' ) );559 $this->assertFalse( bp_cache_get( 'directory_pages', 'bp' ) ); 560 560 561 561 bp_update_option( 'bp-pages', $v ); 562 562 } … … 575 575 576 576 bp_update_option( $key, 'foo' ); 577 577 578 $this->assertFalse( wp_cache_get( 'root_blog_options', 'bp' ), 'Cache not invalidated after updating "' . $key . '"' );578 $this->assertFalse( bp_cache_get( 'root_blog_options', 'bp' ), 'Cache not invalidated after updating "' . $key . '"' ); 579 579 } 580 580 581 581 if ( is_multisite() ) { … … 591 591 592 592 update_site_option( $ms_key, 'foooooooo' ); 593 593 594 $this->assertFalse( wp_cache_get( 'root_blog_options', 'bp' ), 'Cache not invalidated after updating "' . $ms_key . '"' );594 $this->assertFalse( bp_cache_get( 'root_blog_options', 'bp' ), 'Cache not invalidated after updating "' . $ms_key . '"' ); 595 595 } 596 596 } 597 597 } -
tests/phpunit/testcases/groups/cache.php
28 28 groups_get_groupmeta( $g1, 'foo' ); 29 29 30 30 // Ensure an empty cache for $g2 31 wp_cache_delete( $g2, 'group_meta' );31 bp_cache_delete( $g2, 'group_meta' ); 32 32 33 33 bp_groups_update_meta_cache( array( $g1, $g2 ) ); 34 34 … … 58 58 ); 59 59 60 60 $found = array( 61 $g1 => wp_cache_get( $g1, 'group_meta' ),62 $g2 => wp_cache_get( $g2, 'group_meta' ),61 $g1 => bp_cache_get( $g1, 'group_meta' ), 62 $g2 => bp_cache_get( $g2, 'group_meta' ), 63 63 ); 64 64 65 65 $this->assertEquals( $expected, $found ); … … 75 75 // Prime cache 76 76 groups_get_group( array( 'group_id' => $g, ) ); 77 77 78 $this->assertNotEmpty( wp_cache_get( $g, 'bp_groups' ) );78 $this->assertNotEmpty( bp_cache_get( $g, 'bp_groups' ) ); 79 79 80 80 // Trigger flush 81 81 groups_update_groupmeta( $g, 'foo', 'bar' ); 82 82 83 $this->assertFalse( wp_cache_get( $g, 'bp_groups' ) );83 $this->assertFalse( bp_cache_get( $g, 'bp_groups' ) ); 84 84 } 85 85 86 86 /** … … 94 94 groups_update_groupmeta( $g, 'foo', 'bar' ); 95 95 groups_get_group( array( 'group_id' => $g ) ); 96 96 97 $this->assertNotEmpty( wp_cache_get( $g, 'bp_groups' ) );97 $this->assertNotEmpty( bp_cache_get( $g, 'bp_groups' ) ); 98 98 99 99 // Trigger flush 100 100 groups_update_groupmeta( $g, 'foo', 'baz' ); 101 $this->assertFalse( wp_cache_get( $g, 'bp_groups' ) );101 $this->assertFalse( bp_cache_get( $g, 'bp_groups' ) ); 102 102 } 103 103 104 104 /** … … 122 122 123 123 // This assertion is not really necessary - just checks to see 124 124 // whether a fatal error has occurred above 125 $this->assertNotEmpty( wp_cache_get( $g, 'bp_groups' ) );125 $this->assertNotEmpty( bp_cache_get( $g, 'bp_groups' ) ); 126 126 } 127 127 128 128 /** … … 151 151 152 152 bp_groups_prefetch_activity_object_data( $activities ); 153 153 154 $this->assertNotEmpty( wp_cache_get( $g1, 'bp_groups' ) );155 $this->assertNotEmpty( wp_cache_get( $g2, 'bp_groups' ) );154 $this->assertNotEmpty( bp_cache_get( $g1, 'bp_groups' ) ); 155 $this->assertNotEmpty( bp_cache_get( $g2, 'bp_groups' ) ); 156 156 } 157 157 158 158 /** … … 174 174 groups_promote_member( $u2, $g, 'admin' ); 175 175 176 176 // assert that cache is invalidated 177 $this->assertEmpty( wp_cache_get( $g, 'bp_group_admins' ) );177 $this->assertEmpty( bp_cache_get( $g, 'bp_group_admins' ) ); 178 178 179 179 // assert new cached value 180 180 $this->assertEquals( 2, count( groups_get_group_admins( $g ) ) ); … … 195 195 self::add_user_to_group( $u2, $g, array( 'is_admin' => 1 ) ); 196 196 197 197 // assert that cache is invalidated 198 $this->assertEmpty( wp_cache_get( $g, 'bp_group_admins' ) );198 $this->assertEmpty( bp_cache_get( $g, 'bp_group_admins' ) ); 199 199 200 200 // assert new cached value 201 201 $this->assertEquals( 2, count( groups_get_group_admins( $g ) ) ); -
tests/phpunit/testcases/groups/class-bp-groups-group.php
841 841 // Prime cache 842 842 groups_get_group( array( 'group_id' => $g, ) ); 843 843 844 $this->assertNotEmpty( wp_cache_get( $g, 'bp_groups' ) );844 $this->assertNotEmpty( bp_cache_get( $g, 'bp_groups' ) ); 845 845 846 846 $group = new BP_Groups_Group( $g ); 847 847 $group->delete(); 848 848 849 $this->assertFalse( wp_cache_get( $g, 'bp_groups' ) );849 $this->assertFalse( bp_cache_get( $g, 'bp_groups' ) ); 850 850 } 851 851 852 852 /** … … 859 859 // Prime cache 860 860 groups_get_group( array( 'group_id' => $g, ) ); 861 861 862 $this->assertNotEmpty( wp_cache_get( $g, 'bp_groups' ) );862 $this->assertNotEmpty( bp_cache_get( $g, 'bp_groups' ) ); 863 863 864 864 $group = new BP_Groups_Group( $g ); 865 865 $group->name = 'Foo'; 866 866 $group->save(); 867 867 868 $this->assertFalse( wp_cache_get( $g, 'bp_groups' ) );868 $this->assertFalse( bp_cache_get( $g, 'bp_groups' ) ); 869 869 } 870 870 /** 871 871 * @group get_group_extras -
tests/phpunit/testcases/groups/functions.php
443 443 // Get rid of any auto-created values 444 444 global $wpdb, $bp; 445 445 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_groupmeta} WHERE group_id = %d", $g ) ); 446 wp_cache_delete( $g, 'group_meta' );446 bp_cache_delete( $g, 'group_meta' ); 447 447 448 448 $metas = groups_get_groupmeta( $g ); 449 449 $this->assertSame( array(), $metas ); … … 489 489 $g = $this->factory->group->create(); 490 490 groups_add_groupmeta( $g, 'foo', 'bar' ); 491 491 groups_add_groupmeta( $g, 'foo1', 'baz' ); 492 $this->assertFalse( wp_cache_get( $g, 'group_meta' ) );492 $this->assertFalse( bp_cache_get( $g, 'group_meta' ) ); 493 493 494 494 // A single query should prime the whole meta cache 495 495 groups_get_groupmeta( $g, 'foo' ); 496 496 497 $c = wp_cache_get( $g, 'group_meta' );497 $c = bp_cache_get( $g, 'group_meta' ); 498 498 $this->assertNotEmpty( $c['foo1'] ); 499 499 } 500 500 -
tests/phpunit/testcases/members/cache.php
13 13 global $wpdb; 14 14 15 15 // set cached value to zero 16 wp_cache_set( 'bp_total_member_count', 0, 'bp' );16 bp_cache_set( 'bp_total_member_count', 0, 'bp' ); 17 17 $num_queries = $wpdb->num_queries; 18 18 19 19 // run function -
tests/phpunit/testcases/members/functions.php
125 125 ) ); 126 126 bp_core_get_user_displayname( $u ); 127 127 128 $this->assertSame( 'Foo', wp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) );128 $this->assertSame( 'Foo', bp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) ); 129 129 130 130 if ( ! $xprofile_is_active ) { 131 131 unset( buddypress()->active_components['xprofile'] ); … … 143 143 $u = $this->factory->user->create(); 144 144 xprofile_set_field_data( 1, $u, 'Foo Foo' ); 145 145 146 $this->assertFalse( wp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) );146 $this->assertFalse( bp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) ); 147 147 148 148 if ( ! $xprofile_is_active ) { 149 149 unset( buddypress()->active_components['xprofile'] ); … … 182 182 // field through the API 183 183 global $wpdb, $bp; 184 184 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u ) ); 185 wp_cache_delete( 'bp_user_fullname_' . $u, 'bp' );186 wp_cache_delete( 1, 'bp_xprofile_data_' . $u, 'bp' );185 bp_cache_delete( 'bp_user_fullname_' . $u, 'bp' ); 186 bp_cache_delete( 1, 'bp_xprofile_data_' . $u, 'bp' ); 187 187 188 188 $this->assertSame( '', xprofile_get_field_data( 1, $u ) ); 189 189 $this->assertSame( 'Foo Foo', bp_core_get_user_displayname( $u ) ); … … 234 234 // field through the API 235 235 global $wpdb, $bp; 236 236 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u2 ) ); 237 wp_cache_delete( 'bp_user_fullname_' . $u2, 'bp' );238 wp_cache_delete( 1, 'bp_xprofile_data_' . $u2, 'bp' );237 bp_cache_delete( 'bp_user_fullname_' . $u2, 'bp' ); 238 bp_cache_delete( 1, 'bp_xprofile_data_' . $u2, 'bp' ); 239 239 240 240 $expected = array( 241 241 $u1 => 'Foo', … … 254 254 255 255 // Fake the cache for $u2 256 256 $u2 = 123; 257 wp_cache_set( 'bp_user_fullname_' . $u2, 'Bar', 'bp' );257 bp_cache_set( 'bp_user_fullname_' . $u2, 'Bar', 'bp' ); 258 258 259 259 $expected = array( 260 260 $u1 => 'Foo', -
tests/phpunit/testcases/members/template.php
106 106 // confused. Never comes up when BP runs normally, because the 107 107 // loggedin_user doesn't change on a pageload. @todo Fix for 108 108 // real in BP 109 wp_cache_delete( 'bp_user_domain_' . $u2, 'bp' );109 bp_cache_delete( 'bp_user_domain_' . $u2, 'bp' ); 110 110 111 111 $this->go_to( bp_core_get_user_domain( $u2 ) . bp_get_friends_slug() . '/requests/' ); 112 112 $this->restore_admins(); -
tests/phpunit/testcases/members/types.php
137 137 wp_delete_user( $u ); 138 138 } 139 139 140 $this->assertFalse( wp_cache_get( $u, 'bp_member_type' ) );140 $this->assertFalse( bp_cache_get( $u, 'bp_member_type' ) ); 141 141 $this->assertFalse( bp_get_member_type( $u ) ); 142 142 } 143 143 } -
tests/phpunit/testcases/messages/cache.php
42 42 bp_messages_get_meta( $m1, 'utensil' ); 43 43 44 44 // Ensure an empty cache for second message 45 wp_cache_delete( $m2, 'message_meta' );45 bp_cache_delete( $m2, 'message_meta' ); 46 46 47 47 // update message meta cache 48 48 bp_messages_update_meta_cache( array( $m1, $m2 ) ); … … 70 70 ); 71 71 72 72 $found = array( 73 $m1 => wp_cache_get( $m1, 'message_meta' ),74 $m2 => wp_cache_get( $m2, 'message_meta' ),73 $m1 => bp_cache_get( $m1, 'message_meta' ), 74 $m2 => bp_cache_get( $m2, 'message_meta' ), 75 75 ); 76 76 77 77 $this->assertEquals( $expected, $found ); … … 102 102 'update_meta_cache' => true 103 103 ) ); 104 104 105 $this->assertNotEmpty( wp_cache_get( $m1, 'message_meta' ) );105 $this->assertNotEmpty( bp_cache_get( $m1, 'message_meta' ) ); 106 106 } 107 107 108 108 /** … … 147 147 messages_delete_thread( $t1 ); 148 148 149 149 // assert empty meta cache 150 $this->assertEmpty( wp_cache_get( $m1, 'message_meta' ) );151 $this->assertEmpty( wp_cache_get( $m2, 'message_meta' ) );150 $this->assertEmpty( bp_cache_get( $m1, 'message_meta' ) ); 151 $this->assertEmpty( bp_cache_get( $m2, 'message_meta' ) ); 152 152 153 153 // cleanup 154 154 $this->set_current_user( $this->old_current_user ); -
tests/phpunit/testcases/messages/class.bp-messages-notice.php
34 34 35 35 // deactivate notice and make sure cache is invalidated 36 36 $notice->deactivate(); 37 $this->assertFalse( wp_cache_get( 'active_notice', 'bp_messages' ) );37 $this->assertFalse( bp_cache_get( 'active_notice', 'bp_messages' ) ); 38 38 39 39 // create a new notice 40 40 $subject2 = 'Another notice'; … … 45 45 BP_Messages_Notice::get_active(); 46 46 47 47 // grab the cache and make sure it equals our new notice 48 $cache = wp_cache_get( 'active_notice', 'bp_messages' );48 $cache = bp_cache_get( 'active_notice', 'bp_messages' ); 49 49 $this->assertEquals( $subject2, $cache->subject ); 50 50 $this->assertEquals( $message2, $cache->message ); 51 51 } -
tests/phpunit/testcases/notifications/functions.php
29 29 'item_id' => 2, 30 30 ) ); 31 31 32 $this->assertFalse( wp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) );32 $this->assertFalse( bp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) ); 33 33 } 34 34 35 35 public function test_cache_invalidation_all_for_user_on_delete() { … … 52 52 // delete 53 53 BP_Notifications_Notification::delete( array( 'id' => $n1, ) ); 54 54 55 $this->assertFalse( wp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) );55 $this->assertFalse( bp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) ); 56 56 } 57 57 58 58 /** -
tests/phpunit/testcases/xprofile/cache.php
40 40 ), 41 41 ); 42 42 43 $this->assertSame( $g_expected, wp_cache_get( $g, 'xprofile_group_meta' ) );43 $this->assertSame( $g_expected, bp_cache_get( $g, 'xprofile_group_meta' ) ); 44 44 45 45 $f_expected = array( 46 46 'field_foo' => array( … … 48 48 ), 49 49 ); 50 50 51 $this->assertSame( $f_expected, wp_cache_get( $f, 'xprofile_field_meta' ) );51 $this->assertSame( $f_expected, bp_cache_get( $f, 'xprofile_field_meta' ) ); 52 52 53 53 $d_expected = array( 54 54 'data_foo' => array( … … 56 56 ), 57 57 ); 58 58 59 $this->assertSame( $d_expected, wp_cache_get( $d->id, 'xprofile_data_meta' ) );59 $this->assertSame( $d_expected, bp_cache_get( $d->id, 'xprofile_data_meta' ) ); 60 60 } 61 61 62 62 /** … … 94 94 ), 95 95 ); 96 96 97 $this->assertSame( $g_expected, wp_cache_get( $g, 'xprofile_group_meta' ) );97 $this->assertSame( $g_expected, bp_cache_get( $g, 'xprofile_group_meta' ) ); 98 98 99 99 $f_expected = array( 100 100 'field_foo' => array( … … 102 102 ), 103 103 ); 104 104 105 $this->assertSame( $f_expected, wp_cache_get( $f, 'xprofile_field_meta' ) );105 $this->assertSame( $f_expected, bp_cache_get( $f, 'xprofile_field_meta' ) ); 106 106 107 107 $d_expected = array( 108 108 'data_foo' => array( … … 110 110 ), 111 111 ); 112 112 113 $this->assertSame( $d_expected, wp_cache_get( $d->id, 'xprofile_data_meta' ) );113 $this->assertSame( $d_expected, bp_cache_get( $d->id, 'xprofile_data_meta' ) ); 114 114 } 115 115 116 116 /** … … 143 143 'update_meta_cache' => false, 144 144 ) ); 145 145 146 $this->assertFalse( wp_cache_get( $g, 'xprofile_group_meta' ) );147 $this->assertFalse( wp_cache_get( $f, 'xprofile_field_meta' ) );148 $this->assertFalse( wp_cache_get( $d->id, 'xprofile_data_meta' ) );146 $this->assertFalse( bp_cache_get( $g, 'xprofile_group_meta' ) ); 147 $this->assertFalse( bp_cache_get( $f, 'xprofile_field_meta' ) ); 148 $this->assertFalse( bp_cache_get( $d->id, 'xprofile_data_meta' ) ); 149 149 } 150 150 } -
tests/phpunit/testcases/xprofile/class-bp-xprofile-profiledata.php
36 36 37 37 $d = new BP_XProfile_ProfileData( $f, $u ); 38 38 39 wp_cache_delete( $f, 'bp_xprofile_data_' . $u);39 bp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' ); 40 40 41 41 $this->assertTrue( $d->exists() ); 42 42 } … … 56 56 // Fake the cache 57 57 $c = new stdClass; 58 58 $c->id = 3; 59 wp_cache_set( $f, $c, 'bp_xprofile_data_' . $u);59 bp_cache_set( "{$u}:{$f}", $c, 'bp_xprofile_data' ); 60 60 61 61 $this->assertTrue( $d->exists() ); 62 62 } … … 73 73 ) ); 74 74 75 75 // Just to be sure 76 wp_cache_delete( $f, 'bp_xprofile_data_' . $u);76 bp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' ); 77 77 78 78 $this->assertEquals( 0, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) ); 79 79 } … … 96 96 $d->save(); 97 97 98 98 // Ensure it's deleted from cache 99 wp_cache_delete( $f, 'bp_xprofile_data_' . $u);99 bp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' ); 100 100 101 101 $this->assertEquals( $d->id, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) ); 102 102 } … … 115 115 // Fake the cache 116 116 $d = new stdClass; 117 117 $d->id = 5; 118 wp_cache_set( $f, $d, 'bp_xprofile_data_' . $u);118 bp_cache_set( "{$u}:{$f}", $d, 'bp_xprofile_data' ); 119 119 120 120 $this->assertSame( 5, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) ); 121 121 } … … 138 138 $d->save(); 139 139 140 140 // Ensure it's deleted from cache 141 wp_cache_delete( $f, 'bp_xprofile_data_' . $u);141 bp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' ); 142 142 143 143 $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f, $u ) ); 144 144 } … … 179 179 remove_filter( 'xprofile_data_last_updated_before_save', array( $this, 'filter_time' ) ); 180 180 181 181 // Ensure it's deleted from cache 182 wp_cache_delete( $f, 'bp_xprofile_data_' . $u1);183 wp_cache_delete( $f, 'bp_xprofile_data_' . $u2);182 bp_cache_delete( "{$u1}:{$f}", 'bp_xprofile_data' ); 183 bp_cache_delete( "{$u2}:{$f}", 'bp_xprofile_data' ); 184 184 185 185 $eu1 = new stdClass; 186 186 $eu1->user_id = $u1; … … 218 218 $d = new stdClass; 219 219 $d->value = 'foo'; 220 220 $d->field_id = $f; 221 wp_cache_set( $f, $d, 'bp_xprofile_data_' . $u);221 bp_cache_set( "{$u}:{$f}", $d, 'bp_xprofile_data' ); 222 222 223 223 $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f, $u ) ); 224 224 } … … 252 252 $d2->value = 'bar'; 253 253 $d2->last_updated = $time; 254 254 255 wp_cache_set( $f, $d1, 'bp_xprofile_data_' . $u1);256 wp_cache_set( $f, $d2, 'bp_xprofile_data_' . $u2);255 bp_cache_set( "{$u1}:{$f}", $d1, 'bp_xprofile_data' ); 256 bp_cache_set( "{$u2}:{$f}", $d2, 'bp_xprofile_data' ); 257 257 258 258 $eu1 = new stdClass; 259 259 $eu1->id = 10; … … 313 313 $d2->save(); 314 314 315 315 // Ensure it's deleted from cache 316 wp_cache_delete( $f1, 'bp_xprofile_data_' . $u);317 wp_cache_delete( $f2, 'bp_xprofile_data_' . $u);316 bp_cache_delete( "{$u}:{$f1}", 'bp_xprofile_data' ); 317 bp_cache_delete( "{$u}:{$f2}", 'bp_xprofile_data' ); 318 318 319 319 $u_obj = new WP_User( $u ); 320 320 … … 389 389 $d2->last_updated = $time; 390 390 $d2->id = 2; 391 391 392 wp_cache_set( $f1, $d1, 'bp_xprofile_data_' . $u);393 wp_cache_set( $f2, $d2, 'bp_xprofile_data_' . $u);392 bp_cache_set( "{$u}:{$f1}", $d1, 'bp_xprofile_data' ); 393 bp_cache_set( "{$u}:{$f2}", $d2, 'bp_xprofile_data' ); 394 394 395 395 $u_obj = new WP_User( $u ); 396 396 -
tests/phpunit/testcases/xprofile/functions.php
91 91 92 92 bp_update_option( 'bp-xprofile-fullname-field-name', 'foo' ); 93 93 94 $this->assertFalse( wp_cache_get( 'fullname_field_id', 'bp_xprofile' ) );94 $this->assertFalse( bp_cache_get( 'fullname_field_id', 'bp_xprofile' ) ); 95 95 } 96 96 97 97 /**