Skip to:
Content

BuddyPress.org

Ticket #5733: 5733.04.patch

File 5733.04.patch, 48.8 KB (added by johnjamesjacoby, 8 years ago)

Same as 03, but without accidental bp_cache_flush change

  • src/bp-activity/bp-activity-admin.php

     
    542542                $result = $activity->save();
    543543
    544544                // 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' );
    546546
    547547                // Check for any error during activity save
    548548                if ( false === $result )
  • src/bp-activity/bp-activity-cache.php

     
    4242 * @param BP_Activity_Activity $activity
    4343 */
    4444function bp_activity_clear_cache_for_activity( $activity ) {
    45         wp_cache_delete( $activity->id, 'bp_activity' );
     45        bp_cache_delete( $activity->id, 'bp_activity' );
    4646}
    4747add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
    4848
     
    5555 */
    5656function bp_activity_clear_cache_for_deleted_activity( $deleted_ids ) {
    5757        foreach ( (array) $deleted_ids as $deleted_id ) {
    58                 wp_cache_delete( $deleted_id, 'bp_activity' );
     58                bp_cache_delete( $deleted_id, 'bp_activity' );
    5959        }
    6060}
    6161add_action( 'bp_activity_deleted_activities', 'bp_activity_clear_cache_for_deleted_activity' );
  • src/bp-activity/bp-activity-classes.php

     
    137137        public function populate() {
    138138                global $wpdb, $bp;
    139139
    140                 $row = wp_cache_get( $this->id, 'bp_activity' );
     140                $row = bp_cache_get( $this->id, 'bp_activity' );
    141141
    142142                if ( false === $row ) {
    143143                        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
    144144
    145                         wp_cache_set( $this->id, $row, 'bp_activity' );
     145                        bp_cache_set( $this->id, $row, 'bp_activity' );
    146146                }
    147147
    148148                if ( ! empty( $row ) ) {
     
    645645                        // Put that data into the placeholders created earlier,
    646646                        // and add it to the cache
    647647                        foreach ( (array) $queried_adata as $adata ) {
    648                                 wp_cache_set( $adata->id, $adata, 'bp_activity' );
     648                                bp_cache_set( $adata->id, $adata, 'bp_activity' );
    649649                        }
    650650                }
    651651
    652652                // Now fetch data from the cache
    653653                foreach ( $activity_ids as $activity_id ) {
    654                         $activities[] = wp_cache_get( $activity_id, 'bp_activity' );
     654                        $activities[] = bp_cache_get( $activity_id, 'bp_activity' );
    655655                }
    656656
    657657                // Then fetch user data
     
    12691269                        $top_level_parent_id = $activity_id;
    12701270                }
    12711271
    1272                 $comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
     1272                $comments = bp_cache_get( $activity_id, 'bp_activity_comments' );
    12731273
    12741274                // We store the string 'none' to cache the fact that the
    12751275                // activity item has no comments
     
    13941394                                $cache_value = $comments;
    13951395                        }
    13961396
    1397                         wp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );
     1397                        bp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );
    13981398                }
    13991399
    14001400                return $comments;
  • src/bp-activity/bp-activity-functions.php

     
    13961396 * @see BP_Activity_Activity::get() For more information on accepted arguments
    13971397 *      and the format of the returned value.
    13981398 * @uses wp_parse_args()
    1399  * @uses wp_cache_get()
    1400  * @uses wp_cache_set()
     1399 * @uses bp_cache_get()
     1400 * @uses bp_cache_set()
    14011401 * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
    14021402 * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
    14031403 *
     
    14411441        // Attempt to return a cached copy of the first page of sitewide activity.
    14421442        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'] ) ) {
    14431443
    1444                 $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
     1444                $activity = bp_cache_get( 'bp_activity_sitewide_front', 'bp' );
    14451445                if ( false === $activity ) {
    14461446
    14471447                        $activity = BP_Activity_Activity::get( array(
     
    14621462                                'count_total'       => $r['count_total'],
    14631463                        ) );
    14641464
    1465                         wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
     1465                        bp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
    14661466                }
    14671467
    14681468        } else {
     
    15611561 * @uses wp_parse_args()
    15621562 * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
    15631563 * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
    1564  * @uses wp_cache_delete()
     1564 * @uses bp_cache_delete()
    15651565 * @uses do_action() To call the 'bp_activity_add' hook
    15661566 *
    15671567 * @param array $args {
     
    16461646        // If this is an activity comment, rebuild the tree
    16471647        if ( 'activity_comment' === $activity->type ) {
    16481648                // 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' );
    16501650
    16511651                BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
    16521652        }
    16531653
    1654         wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
     1654        bp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    16551655
    16561656        /**
    16571657         * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID.
     
    20022002 * @uses bp_activity_add()
    20032003 * @uses apply_filters() To call the 'bp_activity_comment_action' hook.
    20042004 * @uses apply_filters() To call the 'bp_activity_comment_content' hook.
    2005  * @uses wp_cache_delete()
     2005 * @uses bp_cache_delete()
    20062006 * @uses do_action() To call the 'bp_activity_comment_posted' hook.
    20072007 *
    20082008 * @param array $args {
     
    20862086        ) );
    20872087
    20882088        // 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' );
    20902090
    20912091        // Walk the tree to clear caches for all parent items
    20922092        $clear_id = $r['parent_id'];
    20932093        while ( $clear_id != $activity_id ) {
    20942094                $clear_object = new BP_Activity_Activity( $clear_id );
    2095                 wp_cache_delete( $clear_id, 'bp_activity' );
     2095                bp_cache_delete( $clear_id, 'bp_activity' );
    20962096                $clear_id = intval( $clear_object->secondary_item_id );
    20972097        }
    2098         wp_cache_delete( $activity_id, 'bp_activity' );
     2098        bp_cache_delete( $activity_id, 'bp_activity' );
    20992099
    21002100        /**
    21012101         * Fires near the end of an activity comment posting, before the returning of the comment ID.
     
    21852185 * @uses bp_delete_user_meta()
    21862186 * @uses do_action() To call the 'bp_activity_delete' hook.
    21872187 * @uses do_action() To call the 'bp_activity_deleted_activities' hook.
    2188  * @uses wp_cache_delete()
     2188 * @uses bp_cache_delete()
    21892189 *
    21902190 * @param array $args To delete specific activity items, use
    21912191 *            $args = array( 'id' => $ids );
     
    22572257         */
    22582258        do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
    22592259
    2260         wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
     2260        bp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    22612261
    22622262        return true;
    22632263}
     
    23982398        }
    23992399
    24002400        // 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' );
    24022402
    24032403        // Recalculate the comment tree
    24042404        BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
     
    26322632        $activity->is_spam = 1;
    26332633
    26342634        // 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' );
    26362636
    26372637        // 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' );
    26392639
    26402640        // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
    26412641        if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
     
    26792679        $activity->is_spam = 0;
    26802680
    26812681        // 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' );
    26832683
    26842684        // 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' );
    26862686
    26872687        // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
    26882688        if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
  • src/bp-activity/bp-activity-loader.php

     
    362362
    363363                parent::setup_actions();
    364364        }
     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        }
    365382}
    366383
    367384/**
  • src/bp-blogs/bp-blogs-cache.php

     
    4444 */
    4545function bp_blogs_clear_blog_object_cache( $blog_id = 0, $user_id = 0 ) {
    4646        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' );
    4949        }
    5050
    51         wp_cache_delete( 'bp_total_blogs', 'bp' );
     51        bp_cache_delete( 'bp_total_blogs', 'bp' );
    5252}
    5353
    5454// List actions to clear object caches on
  • src/bp-blogs/bp-blogs-functions.php

     
    128128        foreach ( (array) $blog_ids as $blog_id ) {
    129129
    130130                // 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' );
    132132
    133133                // Get all users
    134134                $users = get_users( array(
     
    11441144 * @return int $count Total blog count.
    11451145 */
    11461146function bp_blogs_total_blogs() {
    1147         $count = wp_cache_get( 'bp_total_blogs', 'bp' );
     1147        $count = bp_cache_get( 'bp_total_blogs', 'bp' );
    11481148
    11491149        if ( false === $count ) {
    11501150                $blogs = BP_Blogs_Blog::get_all();
    11511151                $count = $blogs['total'];
    1152                 wp_cache_set( 'bp_total_blogs', $count, 'bp' );
     1152                bp_cache_set( 'bp_total_blogs', $count, 'bp' );
    11531153        }
    11541154        return $count;
    11551155}
     
    11731173                return 0;
    11741174        }
    11751175
    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' );
    11771177        if ( false === $count ) {
    11781178                $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' );
    11801180        }
    11811181
    11821182        return $count;
  • src/bp-blogs/bp-blogs-loader.php

     
    272272        }
    273273
    274274        /**
     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        /**
    275290         * Set up the tracking arguments for the 'post' post type.
    276291         *
    277292         * @since BuddyPress (2.2.0)
  • src/bp-friends/bp-friends-cache.php

     
    2323        if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) )
    2424                return false;
    2525
    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' );
    2828}
    2929
    3030// List actions to clear object caches on
     
    3939 * @param int $friend_user_id The user ID not initiating the friendship
    4040 */
    4141function 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' );
    4343}
    4444
    4545/**
  • src/bp-friends/bp-friends-classes.php

     
    240240         * @return array|bool An array of user IDs, or false if none are found.
    241241         */
    242242        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' );
    244244
    245245                if ( false === $friend_requests ) {
    246246                        global $wpdb, $bp;
    247247
    248248                        $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 ) );
    249249
    250                         wp_cache_set( $user_id, $friend_requests, 'bp_friends_requests' );
     250                        bp_cache_set( $user_id, $friend_requests, 'bp_friends_requests' );
    251251                }
    252252
    253253                return $friend_requests;
  • src/bp-friends/bp-friends-loader.php

     
    239239
    240240                parent::setup_title();
    241241        }
     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        }
    242257}
    243258
    244259/**
  • src/bp-friends/bp-friends-template.php

     
    7373 */
    7474function bp_friends_random_friends() {
    7575
    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' ) ) {
    7777                $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' );
    7979        } ?>
    8080
    8181        <div class="info-group">
     
    121121 */
    122122function bp_friends_random_members( $total_members = 5 ) {
    123123
    124         if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
     124        if ( !$user_ids = bp_cache_get( 'friends_random_users', 'bp' ) ) {
    125125                $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' );
    127127        }
    128128
    129129        ?>
     
    494494        function bp_get_friend_friendship_id() {
    495495                global $members_template;
    496496
    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() ) ) {
    498498                        $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' );
    500500                }
    501501
    502502                /**
     
    523523        function bp_get_friend_accept_request_link() {
    524524                global $members_template;
    525525
    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() ) ) {
    527527                        $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' );
    529529                }
    530530
    531531                /**
     
    552552        function bp_get_friend_reject_request_link() {
    553553                global $members_template;
    554554
    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() ) ) {
    556556                        $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' );
    558558                }
    559559
    560560                /**
  • src/bp-groups/bp-groups-activity.php

     
    213213                // rather than manually
    214214                $uncached_ids = array();
    215215                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' ) ) {
    217217                                $uncached_ids[] = $group_id;
    218218                        }
    219219                }
     
    224224                        $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
    225225                        $groups = $wpdb->get_results( "SELECT * FROM {$bp->groups->table_name} WHERE id IN ({$uncached_ids_sql})" );
    226226                        foreach ( $groups as $group ) {
    227                                 wp_cache_set( $group->id, $group, 'bp_groups' );
     227                                bp_cache_set( $group->id, $group, 'bp_groups' );
    228228                        }
    229229                }
    230230        }
  • src/bp-groups/bp-groups-cache.php

     
    4848 * @param $group_id Not used.
    4949 */
    5050function 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' );
    5252}
    5353add_action( 'groups_group_deleted',              'groups_clear_group_object_cache' );
    5454add_action( 'groups_settings_updated',           'groups_clear_group_object_cache' );
     
    6464 * @param int $group_id The group being edited.
    6565 */
    6666function bp_groups_delete_group_cache( $group_id = 0 ) {
    67         wp_cache_delete( $group_id, 'bp_groups' );
     67        bp_cache_delete( $group_id, 'bp_groups' );
    6868}
    6969add_action( 'groups_delete_group',     'bp_groups_delete_group_cache' );
    7070add_action( 'groups_update_group',     'bp_groups_delete_group_cache' );
     
    7777 * @since BuddyPress (2.0.0)
    7878 */
    7979function 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' );
    8181}
    8282add_action( 'updated_group_meta', 'bp_groups_delete_group_cache_on_metadata_change', 10, 2 );
    8383add_action( 'added_group_meta', 'bp_groups_delete_group_cache_on_metadata_change', 10, 2 );
     
    121121 * @param int $user_id The user ID.
    122122 */
    123123function 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' );
    125125}
    126126add_action( 'groups_accept_invite', 'bp_groups_clear_invite_count_for_user' );
    127127add_action( 'groups_reject_invite', 'bp_groups_clear_invite_count_for_user' );
     
    164164 * @param int $user_id The user ID.
    165165 */
    166166function 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' );
    168168}
    169169add_action( 'groups_join_group',    'groups_clear_group_user_object_cache', 10, 2 );
    170170add_action( 'groups_leave_group',   'groups_clear_group_user_object_cache', 10, 2 );
     
    181181 * @param int $group_id The group ID.
    182182 */
    183183function 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' );
    185185}
    186186add_action( 'groups_promote_member', 'groups_clear_group_administrator_cache' );
    187187add_action( 'groups_demote_member',  'groups_clear_group_administrator_cache' );
  • src/bp-groups/bp-groups-classes.php

     
    186186                $bp    = buddypress();
    187187
    188188                // Check cache for group data
    189                 $group = wp_cache_get( $this->id, 'bp_groups' );
     189                $group = bp_cache_get( $this->id, 'bp_groups' );
    190190
    191191                // Cache missed, so query the DB
    192192                if ( false === $group ) {
    193193                        $group = $wpdb->get_row( $wpdb->prepare( "SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id = %d", $this->id ) );
    194194
    195                         wp_cache_set( $this->id, $group, 'bp_groups' );
     195                        bp_cache_set( $this->id, $group, 'bp_groups' );
    196196                }
    197197
    198198                // No group found so set the ID and bail
     
    344344
    345345                do_action_ref_array( 'groups_group_after_save', array( &$this ) );
    346346
    347                 wp_cache_delete( $this->id, 'bp_groups' );
     347                bp_cache_delete( $this->id, 'bp_groups' );
    348348
    349349                return true;
    350350        }
     
    372372
    373373                do_action_ref_array( 'bp_groups_delete_group', array( &$this, $user_ids ) );
    374374
    375                 wp_cache_delete( $this->id, 'bp_groups' );
     375                bp_cache_delete( $this->id, 'bp_groups' );
    376376
    377377                // Finally remove the group entry from the DB
    378378                if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
     
    24222422
    24232423                $bp = buddypress();
    24242424
    2425                 $count = wp_cache_get( $user_id, 'bp_group_invite_count' );
     2425                $count = bp_cache_get( $user_id, 'bp_group_invite_count' );
    24262426
    24272427                if ( false === $count ) {
    24282428                        $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' );
    24302430                }
    24312431
    24322432                return $count;
     
    26302630        public static function get_group_administrator_ids( $group_id ) {
    26312631                global $bp, $wpdb;
    26322632
    2633                 $group_admins = wp_cache_get( $group_id, 'bp_group_admins' );
     2633                $group_admins = bp_cache_get( $group_id, 'bp_group_admins' );
    26342634
    26352635                if ( false === $group_admins ) {
    26362636                        $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 ) );
    26372637
    2638                         wp_cache_set( $group_id, $group_admins, 'bp_group_admins' );
     2638                        bp_cache_set( $group_id, $group_admins, 'bp_group_admins' );
    26392639                }
    26402640
    26412641                return $group_admins;
  • src/bp-groups/bp-groups-functions.php

     
    644644 * @return int
    645645 */
    646646function 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' );
    648648
    649649        if ( false === $count ) {
    650650                $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' );
    652652        }
    653653
    654654        return $count;
     
    686686        if ( empty( $user_id ) )
    687687                $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
    688688
    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' );
    690690
    691691        if ( false === $count ) {
    692692                $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' );
    694694        }
    695695
    696696        return $count;
  • src/bp-groups/bp-groups-loader.php

     
    676676
    677677                parent::setup_title();
    678678        }
     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        }
    679696}
    680697
    681698/**
  • src/bp-members/bp-members-cache.php

     
    2222
    2323        $cached_member_ids = array();
    2424        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' );
    2626                $cached_member_ids[] = $member_type->object_id;
    2727        }
    2828
    2929        // Cache an empty value for users with no type.
    3030        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' );
    3232        }
    3333}
    3434add_action( 'bp_user_query_populate_extras', 'bp_members_prefetch_member_type' );
     
    4343 * @param int $user_id ID of the deleted user.
    4444 */
    4545function 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' );
    4747}
    4848add_action( 'wpmu_delete_user', 'bp_members_clear_member_type_cache' );
    4949add_action( 'delete_user', 'bp_members_clear_member_type_cache' );
  • src/bp-members/bp-members-functions.php

     
    200200                return false;
    201201        }
    202202
    203         if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {
     203        if ( !$userdata = bp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {
    204204                $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' );
    206206        }
    207207
    208208        /**
     
    296296        $bp = buddypress();
    297297
    298298        // 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' );
    300300        if ( false === $username ) {
    301301
    302302                // Cache not found so prepare to update it
     
    345345
    346346        // Add this to cache
    347347        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' );
    349349
    350350        // @todo bust this cache if no $username found?
    351351        //} else {
    352         //      wp_cache_delete( 'bp_user_username_' . $user_id );
     352        //      bp_cache_delete( 'bp_user_username_' . $user_id );
    353353        }
    354354
    355355        /**
     
    378378function bp_members_get_user_nicename( $user_id ) {
    379379        $bp = buddypress();
    380380
    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' ) ) {
    382382                $update_cache = true;
    383383
    384384                // User ID matches logged in user
     
    413413
    414414        // Add this to cache
    415415        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' );
    417417        }
    418418
    419419        /**
     
    435435 */
    436436function bp_core_get_user_email( $uid ) {
    437437
    438         if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
     438        if ( !$email = bp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
    439439
    440440                // User exists
    441441                $ud = bp_core_get_core_userdata( $uid );
     
    447447                        $email = '';
    448448                }
    449449
    450                 wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
     450                bp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
    451451        }
    452452
    453453        /**
     
    529529
    530530        $uncached_ids = array();
    531531        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' ) ) {
    533533                        $uncached_ids[] = $user_id;
    534534                }
    535535        }
     
    576576                }
    577577
    578578                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' );
    580580                }
    581581        }
    582582
    583583        $retval = array();
    584584        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' );
    586586        }
    587587
    588588        return $retval;
     
    691691function bp_core_get_total_member_count() {
    692692        global $wpdb;
    693693
    694         $count = wp_cache_get( 'bp_total_member_count', 'bp' );
     694        $count = bp_cache_get( 'bp_total_member_count', 'bp' );
    695695
    696696        if ( false === $count ) {
    697697                $status_sql = bp_core_get_status_sql();
    698698                $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' );
    700700        }
    701701
    702702        /**
     
    25922592
    25932593        // Bust the cache if the type has been updated.
    25942594        if ( ! is_wp_error( $retval ) ) {
    2595                 wp_cache_delete( $user_id, 'bp_member_type' );
     2595                bp_cache_delete( $user_id, 'bp_member_type' );
    25962596
    25972597                /**
    25982598                 * Fires just after a user's member type has been changed.
     
    26212621 *                           types (if $single is false). Returns false on failure.
    26222622 */
    26232623function 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' );
    26252625
    26262626        if ( false === $types ) {
    26272627                $types = bp_get_object_terms( $user_id, 'bp_member_type'  );
    26282628
    26292629                if ( ! is_wp_error( $types ) ) {
    26302630                        $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' );
    26322632                }
    26332633        }
    26342634
  • src/bp-members/bp-members-loader.php

     
    276276
    277277                parent::setup_title();
    278278        }
     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        }
    279294}
    280295
    281296/**
  • src/bp-messages/bp-messages-cache.php

     
    5454 */
    5555function bp_messages_clear_unread_count_cache_on_message_save( BP_Messages_Message $message ) {
    5656        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' );
    5858        }
    5959}
    6060add_action( 'messages_message_after_save', 'bp_messages_clear_unread_count_cache_on_message_save' );
     
    6868 *  array of thread IDs
    6969 */
    7070function 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' );
    7272}
    7373add_action( 'messages_before_delete_thread', 'bp_messages_clear_unread_count_cache_on_message_delete' );
    7474
     
    8080 * @since BuddyPress (2.0.0)
    8181 */
    8282function bp_notices_clear_cache( $notice ) {
    83         wp_cache_delete( 'active_notice', 'bp_messages' );
     83        bp_cache_delete( 'active_notice', 'bp_messages' );
    8484}
    8585add_action( 'messages_notice_after_save',    'bp_notices_clear_cache' );
    8686add_action( 'messages_notice_before_delete', 'bp_notices_clear_cache' );
  • src/bp-messages/bp-messages-classes.php

     
    434434                $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 );
    435435                $wpdb->query($sql);
    436436
    437                 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' );
     437                bp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' );
    438438        }
    439439
    440440        /**
     
    450450                $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 );
    451451                $wpdb->query($sql);
    452452
    453                 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' );
     453                bp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' );
    454454        }
    455455
    456456        /**
     
    533533                        $user_id = bp_loggedin_user_id();
    534534                }
    535535
    536                 $unread_count = wp_cache_get( $user_id, 'bp_messages_unread_count' );
     536                $unread_count = bp_cache_get( $user_id, 'bp_messages_unread_count' );
    537537
    538538                if ( false === $unread_count ) {
    539539                        $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 ) );
    540540
    541                         wp_cache_set( $user_id, $unread_count, 'bp_messages_unread_count' );
     541                        bp_cache_set( $user_id, $unread_count, 'bp_messages_unread_count' );
    542542                }
    543543
    544544                /**
     
    11321132         * @return object The BP_Messages_Notice object
    11331133         */
    11341134        public static function get_active() {
    1135                 $notice = wp_cache_get( 'active_notice', 'bp_messages' );
     1135                $notice = bp_cache_get( 'active_notice', 'bp_messages' );
    11361136
    11371137                if ( false === $notice ) {
    11381138                        global $wpdb, $bp;
     
    11401140                        $notice_id = $wpdb->get_var( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1" );
    11411141                        $notice    = new BP_Messages_Notice( $notice_id );
    11421142
    1143                         wp_cache_set( 'active_notice', $notice, 'bp_messages' );
     1143                        bp_cache_set( 'active_notice', $notice, 'bp_messages' );
    11441144                }
    11451145
    11461146                return $notice;
  • src/bp-messages/bp-messages-loader.php

     
    292292
    293293                parent::setup_title();
    294294        }
     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        }
    295312}
    296313
    297314/**
  • src/bp-notifications/bp-notifications-cache.php

     
    1414 * @param BP_Notification_Notification $n Notification object.
    1515 */
    1616function 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' );
    1818}
    1919add_action( 'bp_notification_after_save', 'bp_notifications_clear_all_for_user_cache_after_save' );
    2020
     
    3535        }
    3636
    3737        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' );
    3939        }
    4040}
    4141add_action( 'bp_notification_before_delete', 'bp_notifications_clear_all_for_user_cache_before_delete' );
  • src/bp-notifications/bp-notifications-classes.php

     
    681681
    682682                // make sure we delete the notification cache for the user on update
    683683                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' );
    685685                }
    686686
    687687                return self::_update( $update['data'], $where['data'], $update['format'], $where['format'] );
  • src/bp-notifications/bp-notifications-functions.php

     
    143143        }
    144144
    145145        // 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' );
    147147        if ( false === $notifications ) {
    148148                $notifications = BP_Notifications_Notification::get( array(
    149149                        'user_id' => $user_id
    150150                ) );
    151                 wp_cache_set( 'all_for_user_' . $user_id, $notifications, 'bp_notifications' );
     151                bp_cache_set( 'all_for_user_' . $user_id, $notifications, 'bp_notifications' );
    152152        }
    153153
    154154        // Filter and return
  • src/bp-notifications/bp-notifications-loader.php

     
    237237
    238238                parent::setup_title();
    239239        }
     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        }
    240255}
    241256
    242257/**
  • src/bp-xprofile/bp-xprofile-cache.php

     
    1313if ( !defined( 'ABSPATH' ) ) exit;
    1414
    1515/**
     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 */
     24function 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 === wp_cache_get( $cache_key, 'bp_xprofile_data' ) ) {
     31                        $uncached_fields[] = $field_id;
     32                }
     33        }
     34
     35        return $uncached_fields;
     36}
     37
     38/**
    1639 * Slurp up xprofilemeta for a specified set of profile objects.
    1740 *
    1841 * We do not use bp_update_meta_cache() for the xprofile component. This is
     
    112135                foreach ( $cache as $object_type => $object_caches ) {
    113136                        $cache_group = $cache_groups[ $object_type ];
    114137                        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 );
    116139                        }
    117140                }
    118141        }
     
    121144}
    122145
    123146function 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' );
    126149}
    127150add_action( 'xprofile_group_after_delete', 'xprofile_clear_profile_groups_object_cache' );
    128151add_action( 'xprofile_group_after_save',   'xprofile_clear_profile_groups_object_cache' );
    129152
    130153function 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' );
    132155}
    133156add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache'   );
    134157
     
    142165 */
    143166function xprofile_clear_fullname_cache_on_profile_field_edit( $data ) {
    144167        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' );
    146169        }
    147170}
    148171add_action( 'xprofile_data_after_save', 'xprofile_clear_fullname_cache_on_profile_field_edit' );
     
    156179 */
    157180function xprofile_clear_profile_field_object_cache( $field_obj ) {
    158181        // Clear default visibility level cache
    159         wp_cache_delete( 'xprofile_default_visibility_levels', 'bp' );
     182        bp_cache_delete( 'xprofile_default_visibility_levels', 'bp' );
    160183
    161184        // Modified fields can alter parent group status, in particular when
    162185        // the group goes from empty to non-empty. Bust its cache, as well as
    163186        // 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' );
    166189}
    167190add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' );
    168191add_action( 'xprofile_fields_deleted_field', 'xprofile_clear_profile_field_object_cache' );
     
    175198 * @param BP_XProfile_ProfileData $data_obj
    176199 */
    177200function 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->field_id, 'bp_xprofile_data_' . $data_obj->user_id );
    179202}
    180203add_action( 'xprofile_data_after_save', 'xprofile_clear_profiledata_object_cache' );
    181204add_action( 'xprofile_data_after_delete', 'xprofile_clear_profiledata_object_cache' );
     
    196219 * @since BuddyPress (2.0.0)
    197220 */
    198221function xprofile_clear_fullname_field_id_cache() {
    199         wp_cache_delete( 'fullname_field_id', 'bp_xprofile' );
     222        bp_cache_delete( 'fullname_field_id', 'bp_xprofile' );
    200223}
    201224add_action( 'update_option_bp-xprofile-fullname-field-name', 'xprofile_clear_fullname_field_id_cache' );
    202225
  • src/bp-xprofile/bp-xprofile-classes.php

     
    2626        public function populate( $id ) {
    2727                global $wpdb, $bp;
    2828
    29                 $group = wp_cache_get( 'xprofile_group_' . $this->id, 'bp' );
     29                $group = bp_cache_get( 'xprofile_group_' . $this->id, 'bp' );
    3030
    3131                if ( false === $group ) {
    3232                        $group = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id ) );
     
    367367                foreach ( $group_ids as $group_id ) {
    368368
    369369                        // 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' ) ) {
    371371                                $groups[ $group_id ] = $group_data;
    372372
    373373                        // Otherwise leave a placeholder so we don't lose the order
     
    392392                        // and add it to the cache
    393393                        foreach ( (array) $queried_gdata as $gdata ) {
    394394                                $groups[ $gdata->id ] = $gdata;
    395                                 wp_cache_set( 'xprofile_group_' . $gdata->id, $gdata, 'bp' );
     395                                bp_cache_set( 'xprofile_group_' . $gdata->id, $gdata, 'bp' );
    396396                        }
    397397                }
    398398
     
    422422                }
    423423
    424424                // purge profile field group cache
    425                 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );
     425                bp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );
    426426
    427427                return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET group_order = %d WHERE id = %d", $position, $field_group_id ) );
    428428        }
     
    482482        public static function fetch_default_visibility_levels() {
    483483                global $wpdb, $bp;
    484484
    485                 $default_visibility_levels = wp_cache_get( 'xprofile_default_visibility_levels', 'bp' );
     485                $default_visibility_levels = bp_cache_get( 'xprofile_default_visibility_levels', 'bp' );
    486486
    487487                if ( false === $default_visibility_levels ) {
    488488                        $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' )" );
     
    497497                                }
    498498                        }
    499499
    500                         wp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, 'bp' );
     500                        bp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, 'bp' );
    501501                }
    502502
    503503                return $default_visibility_levels;
     
    12221222        public function populate( $field_id, $user_id )  {
    12231223                global $wpdb, $bp;
    12241224
    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' );
    12271227
    12281228                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 );
    12301230                        $profiledata = $wpdb->get_row( $sql );
    12311231
    12321232                        if ( $profiledata ) {
    1233                                 wp_cache_set( $field_id, $profiledata, $cache_group );
     1233                                bp_cache_set( $cache_key, $profiledata, 'bp_xprofile_data' );
    12341234                        }
    12351235                }
    12361236
     
    12591259                global $wpdb, $bp;
    12601260
    12611261                // 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' );
    12631264
    12641265                if ( $cached && ! empty( $cached->id ) ) {
    12651266                        $retval = true;
     
    14001401
    14011402                $data = array();
    14021403
    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' );
    14041405
    1405                 $uncached_field_ids = bp_get_non_cached_ids( $field_ids, $cache_group );
    1406 
    14071406                // Prime the cache
    14081407                if ( ! empty( $uncached_field_ids ) ) {
    14091408                        $bp = buddypress();
     
    14261425                        // Set caches
    14271426                        foreach ( $uncached_field_ids as $field_id ) {
    14281427
     1428                                $cache_key = "{$user_id}:{$field_id}";
     1429
    14291430                                // If a value was found, cache it
    14301431                                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' );
    14321433
    14331434                                // If no value was found, cache an empty item
    14341435                                // to avoid future cache misses
     
    14401441                                        $d->value        = '';
    14411442                                        $d->last_updated = '';
    14421443
    1443                                         wp_cache_set( $field_id, $d, $cache_group );
     1444                                        bp_cache_set( $cache_key, $d, 'bp_xprofile_data' );
    14441445                                }
    14451446                        }
    14461447                }
    14471448
    14481449                // Now that all items are cached, fetch them
    14491450                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' );
    14511453                }
    14521454
    14531455                return $data;
     
    14601462         * @return array
    14611463         */
    14621464        public static function get_all_for_user( $user_id ) {
    1463                 global $wpdb, $bp;
    14641465
    14651466                $groups = bp_xprofile_get_groups( array(
    14661467                        'user_id'                => $user_id,
     
    15141515                } else {
    15151516
    15161517                        // 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' );
    15181520                        if ( false === $fielddata || empty( $fielddata->id ) ) {
    15191521                                $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 ) );
    15201522                        } else {
     
    15511553                // Assemble uncached IDs
    15521554                $uncached_ids = array();
    15531555                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' ) ) {
    15551558                                $uncached_ids[] = $user_id;
    15561559                        }
    15571560                }
     
    15831586                                        $d->last_updated = '';
    15841587                                }
    15851588
    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( $field_id, $d, 'bp_xprofile_data' );
    15871591                        }
    15881592                }
    15891593
    15901594                // Now that the cache is primed with all data, fetch it
    15911595                $data = array();
    15921596                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' );
    15941599                }
    15951600
    15961601                // If a single ID was passed, just return the value
  • src/bp-xprofile/bp-xprofile-functions.php

     
    981981 * @return int Field ID.
    982982 */
    983983function 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' );
    985985
    986986        if ( false === $id ) {
    987987                global $wpdb;
     
    989989                $bp = buddypress();
    990990                $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) );
    991991
    992                 wp_cache_set( 'fullname_field_id', $id, 'bp_xprofile' );
     992                bp_cache_set( 'fullname_field_id', $id, 'bp_xprofile' );
    993993        }
    994994
    995995        return absint( $id );
  • src/bp-xprofile/bp-xprofile-loader.php

     
    353353        }
    354354
    355355        /**
     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        /**
    356373         * Adds "Settings > Profile" subnav item under the "Settings" adminbar menu.
    357374         *
    358375         * @since BuddyPress (2.0.0)
  • src/bp-xprofile/bp-xprofile-template.php

     
    801801 * @return object $groups
    802802 */
    803803function 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' );
    805805
    806806        if ( empty( $groups ) ) {
    807807                $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' );
    809809        }
    810810
    811811        /**
     
    899899                if ( !is_numeric( $group_id ) )
    900900                        $group_id = 1;
    901901
    902                 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
     902                if ( !$group = bp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
    903903                        $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' );
    905905                }
    906906
    907907                /**