Skip to:
Content

BuddyPress.org

Ticket #5733: 5733.patch

File 5733.patch, 30.6 KB (added by johnjamesjacoby, 6 years ago)

Proof of concept

  • content/plugins/buddypress/bp-activity/bp-activity-admin.php

    diff --git a/content/plugins/buddypress/bp-activity/bp-activity-admin.php b/content/plugins/buddypress/bp-activity/bp-activity-admin.php
    index 74222e8..a59d98a 100644
    a b  
    506506                $result = $activity->save();
    507507
    508508                // Clear the activity stream first page cache, in case this activity's timestamp was changed
    509                 wp_cache_delete( 'bp_activity_sitewide_front', 'bp_activity' );
     509                wp_cache_delete( 'bp_activity_sitewide_front', bp_core_get_global_cache_key() );
    510510
    511511                // Check for any error during activity save
    512512                if ( false === $result )
  • content/plugins/buddypress/bp-activity/bp-activity-functions.php

    diff --git a/content/plugins/buddypress/bp-activity/bp-activity-functions.php b/content/plugins/buddypress/bp-activity/bp-activity-functions.php
    index d3958f9..a5a1a44 100644
    a b  
    10431043        // Attempt to return a cached copy of the first page of sitewide activity.
    10441044        if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
    10451045
    1046                 $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp_activity' );
     1046                $activity = wp_cache_get( 'bp_activity_sitewide_front', bp_core_get_global_cache_key() );
    10471047                if ( false === $activity ) {
    10481048
    10491049                        $activity = BP_Activity_Activity::get( array(
     
    10621062                                'count_total'       => $r['count_total'],
    10631063                        ) );
    10641064
    1065                         wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp_activity' );
     1065                        wp_cache_set( 'bp_activity_sitewide_front', $activity, bp_core_get_global_cache_key() );
    10661066                }
    10671067
    10681068        } else {
     
    12321232                BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
    12331233        }
    12341234
    1235         wp_cache_delete( 'bp_activity_sitewide_front', 'bp_activity' );
     1235        wp_cache_delete( 'bp_activity_sitewide_front', bp_core_get_global_cache_key() );
    12361236        do_action( 'bp_activity_add', $r );
    12371237
    12381238        return $activity->id;
     
    14951495        do_action( 'bp_activity_delete', $args );
    14961496        do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
    14971497
    1498         wp_cache_delete( 'bp_activity_sitewide_front', 'bp_activity' );
     1498        wp_cache_delete( 'bp_activity_sitewide_front', bp_core_get_global_cache_key() );
    14991499
    15001500        return true;
    15011501}
     
    18171817        $activity->is_spam = 1;
    18181818
    18191819        // Clear the activity stream first page cache
    1820         wp_cache_delete( 'bp_activity_sitewide_front', 'bp_activity' );
     1820        wp_cache_delete( 'bp_activity_sitewide_front', bp_core_get_global_cache_key() );
    18211821
    18221822        // Clear the activity comment cache for this activity item
    18231823        wp_cache_delete( $activity->id, 'bp_activity_comments' );
     
    18551855        $activity->is_spam = 0;
    18561856
    18571857        // Clear the activity stream first page cache
    1858         wp_cache_delete( 'bp_activity_sitewide_front', 'bp_activity' );
     1858        wp_cache_delete( 'bp_activity_sitewide_front', bp_core_get_global_cache_key() );
    18591859
    18601860        // Clear the activity comment cache for this activity item
    18611861        wp_cache_delete( $activity->id, 'bp_activity_comments' );
  • content/plugins/buddypress/bp-blogs/bp-blogs-cache.php

    diff --git a/content/plugins/buddypress/bp-blogs/bp-blogs-cache.php b/content/plugins/buddypress/bp-blogs/bp-blogs-cache.php
    index c16fba9..bddfb72 100644
    a b  
    4343 * @param int $user_id ID of the user whose blog cache should be cleared.
    4444 */
    4545function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
    46         wp_cache_delete( 'bp_blogs_of_user_'        . $user_id, 'bp' );
    47         wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
     46        wp_cache_delete( 'bp_blogs_of_user_'        . $user_id, bp_core_get_global_cache_key() );
     47        wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, bp_core_get_global_cache_key() );
    4848}
    4949
    5050/**
     
    5757 */
    5858function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
    5959        bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
    60         wp_cache_delete( 'bp_total_blogs', 'bp' );
     60        wp_cache_delete( 'bp_total_blogs', bp_core_get_global_cache_key() );
    6161}
    6262
    6363// List actions to clear object caches on
  • content/plugins/buddypress/bp-blogs/bp-blogs-functions.php

    diff --git a/content/plugins/buddypress/bp-blogs/bp-blogs-functions.php b/content/plugins/buddypress/bp-blogs/bp-blogs-functions.php
    index ea472ad..d48b2e5 100644
    a b  
    12081208 * @return int $count Total blog count.
    12091209 */
    12101210function bp_blogs_total_blogs() {
    1211         if ( !$count = wp_cache_get( 'bp_total_blogs', 'bp' ) ) {
     1211        if ( !$count = wp_cache_get( 'bp_total_blogs', bp_core_get_global_cache_key() ) ) {
    12121212                $blogs = BP_Blogs_Blog::get_all();
    12131213                $count = $blogs['total'];
    1214                 wp_cache_set( 'bp_total_blogs', $count, 'bp' );
     1214                wp_cache_set( 'bp_total_blogs', $count, bp_core_get_global_cache_key() );
    12151215        }
    12161216        return $count;
    12171217}
     
    12351235                return 0;
    12361236        }
    12371237
    1238         $count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
     1238        $count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, bp_core_get_global_cache_key() );
    12391239        if ( false === $count ) {
    12401240                $count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
    1241                 wp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, 'bp' );
     1241                wp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, bp_core_get_global_cache_key() );
    12421242        }
    12431243
    12441244        return $count;
  • content/plugins/buddypress/bp-core/bp-core-cache.php

    diff --git a/content/plugins/buddypress/bp-core/bp-core-cache.php b/content/plugins/buddypress/bp-core/bp-core-cache.php
    index 340bbb2..02d566c 100644
    a b  
    2727}
    2828
    2929/**
    30  * Add 'bp' to global group of network wide cachable objects.
     30 * Return global cache key filtered with `bp_core_get_global_cache_key`
     31 *
     32 * The filter is intended primarily for use in multiblog mode and multinetwork
     33 * installations.
     34 *
     35 * @return string Filtered global cache key.
     36 */
     37function bp_core_get_global_cache_key() {
     38        return apply_filters( 'bp_core_get_global_cache_key', 'bp' );
     39}
     40
     41/**
     42 * Return array of global cache groups, filtered with `bp_core_get_global_cache_groups`
     43 *
     44 * The filter is intended primarily for use in multiblog mode and multinetwork
     45 * installations.
     46 *
     47 * @return array
     48 */
     49function bp_core_get_global_cache_groups() {
     50        return apply_filters( 'bp_core_get_global_cache_groups', array( bp_core_get_global_cache_key() ) );
     51}
     52
     53/**
     54 * Add global cache group of network wide cachable objects.
    3155 */
    3256function bp_core_add_global_group() {
    3357        if ( function_exists( 'wp_cache_add_global_groups' ) ) {
    34                 wp_cache_add_global_groups( array( 'bp' ) );
     58                wp_cache_add_global_groups( bp_core_get_global_cache_groups() );
    3559        }
    3660}
    3761add_action( 'bp_loaded', 'bp_core_add_global_group' );
     
    4064 * Clear all cached objects for a user, or those that a user is part of.
    4165 */
    4266function bp_core_clear_user_object_cache( $user_id ) {
    43         wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
     67        wp_cache_delete( 'bp_user_' . $user_id, bp_core_get_global_cache_key() );
    4468}
    4569
    4670/**
    4771 * Clear member count caches and transients.
    4872 */
    4973function bp_core_clear_member_count_caches() {
    50         wp_cache_delete( 'bp_total_member_count', 'bp' );
     74        wp_cache_delete( 'bp_total_member_count', bp_core_get_global_cache_key() );
    5175        delete_transient( 'bp_active_member_count' );
    5276}
    5377add_action( 'bp_core_activated_user',         'bp_core_clear_member_count_caches' );
     
    79103                return;
    80104        }
    81105
    82         wp_cache_delete( 'directory_pages', 'bp' );
     106        wp_cache_delete( 'directory_pages', bp_core_get_global_cache_key() );
    83107}
    84108add_action( 'save_post', 'bp_core_clear_directory_pages_cache_page_edit' );
    85109
     
    92116 */
    93117function bp_core_clear_directory_pages_cache_settings_edit( $option ) {
    94118        if ( 'bp-pages' === $option ) {
    95                 wp_cache_delete( 'directory_pages', 'bp' );
     119                wp_cache_delete( 'directory_pages', bp_core_get_global_cache_key() );
    96120        }
    97121}
    98122add_action( 'update_option', 'bp_core_clear_directory_pages_cache_settings_edit' );
     
    116140        ) );
    117141
    118142        if ( in_array( $option, $keys ) ) {
    119                 wp_cache_delete( 'root_blog_options', 'bp' );
     143                wp_cache_delete( 'root_blog_options', bp_core_get_global_cache_key() );
    120144        }
    121145}
    122146add_action( 'update_option', 'bp_core_clear_root_options_cache' );
  • content/plugins/buddypress/bp-core/bp-core-classes.php

    diff --git a/content/plugins/buddypress/bp-core/bp-core-classes.php b/content/plugins/buddypress/bp-core/bp-core-classes.php
    index 8977494..bdc2bb6 100644
    a b  
    486486                // only uncached users. However, BP does cache this data, so
    487487                // we set it here.
    488488                foreach ( $wp_user_query->results as $u ) {
    489                         wp_cache_set( 'bp_core_userdata_' . $u->ID, $u, 'bp' );
     489                        wp_cache_set( 'bp_core_userdata_' . $u->ID, $u, bp_core_get_global_cache_key() );
    490490                }
    491491
    492492                // We calculate total_users using a standalone query, except
     
    828828                }
    829829
    830830                // Cache a few things that are fetched often
    831                 wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
    832                 wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
    833                 wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
     831                wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, bp_core_get_global_cache_key() );
     832                wp_cache_set( 'bp_user_email_' . $this->id, $this->email, bp_core_get_global_cache_key() );
     833                wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, bp_core_get_global_cache_key() );
    834834
    835835                $this->avatar       = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
    836836                $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
  • content/plugins/buddypress/bp-core/bp-core-functions.php

    diff --git a/content/plugins/buddypress/bp-core/bp-core-functions.php b/content/plugins/buddypress/bp-core/bp-core-functions.php
    index 5b93f9c..8d5a96e 100644
    a b  
    416416        global $wpdb;
    417417
    418418        // Look in cache first
    419         $pages = wp_cache_get( 'directory_pages', 'bp' );
     419        $pages = wp_cache_get( 'directory_pages', bp_core_get_global_cache_key() );
    420420
    421421        if ( false === $pages ) {
    422422
     
    460460                        }
    461461                }
    462462
    463                 wp_cache_set( 'directory_pages', $pages, 'bp' );
     463                wp_cache_set( 'directory_pages', $pages, bp_core_get_global_cache_key() );
    464464        }
    465465
    466466        return apply_filters( 'bp_core_get_directory_pages', $pages );
  • content/plugins/buddypress/bp-core/bp-core-options.php

    diff --git a/content/plugins/buddypress/bp-core/bp-core-options.php b/content/plugins/buddypress/bp-core/bp-core-options.php
    index f927069..de12b6d 100644
    a b  
    343343        // Check cache first - We cache here instead of using the standard WP
    344344        // settings cache because the current blog may not be the root blog,
    345345        // 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 = wp_cache_get( 'root_blog_options', bp_core_get_global_cache_key() );
    347347
    348348        if ( false === $root_blog_options_meta ) {
    349349                $blog_options_keys      = "'" . join( "', '", (array) $root_blog_option_keys ) . "'";
     
    426426                        unset( $root_blog_options );
    427427                }
    428428
    429                 wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' );
     429                wp_cache_set( 'root_blog_options', $root_blog_options_meta, bp_core_get_global_cache_key() );
    430430        }
    431431
    432432        return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta );
  • content/plugins/buddypress/bp-core/deprecated/2.1.php

    diff --git a/content/plugins/buddypress/bp-core/deprecated/2.1.php b/content/plugins/buddypress/bp-core/deprecated/2.1.php
    index 9ad16e9..d6512cb 100644
    a b  
    104104        if ( !is_multisite() )
    105105                return false;
    106106
    107         $blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp' );
     107        $blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', bp_core_get_global_cache_key() );
    108108        if ( empty( $blogs ) ) {
    109109                $blogs = bp_blogs_get_blogs_for_user( bp_loggedin_user_id(), true );
    110                 wp_cache_set( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', $blogs, 'bp' );
     110                wp_cache_set( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', $blogs, bp_core_get_global_cache_key() );
    111111        }
    112112
    113113        $counter = 0;
  • content/plugins/buddypress/bp-friends/bp-friends-cache.php

    diff --git a/content/plugins/buddypress/bp-friends/bp-friends-cache.php b/content/plugins/buddypress/bp-friends/bp-friends-cache.php
    index 417525c..a733cf9 100644
    a b  
    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        wp_cache_delete( 'friends_friend_ids_' .    $friendship->initiator_user_id, bp_core_get_global_cache_key() );
     27        wp_cache_delete( 'friends_friend_ids_' .    $friendship->friend_user_id,    bp_core_get_global_cache_key() );
    2828}
    2929
    3030// List actions to clear object caches on
  • content/plugins/buddypress/bp-friends/bp-friends-template.php

    diff --git a/content/plugins/buddypress/bp-friends/bp-friends-template.php b/content/plugins/buddypress/bp-friends/bp-friends-template.php
    index d9ffa8d..cf0b362 100644
    a b  
    5757 */
    5858function bp_friends_random_friends() {
    5959
    60         if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) {
     60        if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), bp_core_get_global_cache_key() ) ) {
    6161                $friend_ids = BP_Friends_Friendship::get_random_friends( bp_displayed_user_id() );
    62                 wp_cache_set( 'friends_friend_ids_' . bp_displayed_user_id(), $friend_ids, 'bp' );
     62                wp_cache_set( 'friends_friend_ids_' . bp_displayed_user_id(), $friend_ids, bp_core_get_global_cache_key() );
    6363        } ?>
    6464
    6565        <div class="info-group">
     
    105105 */
    106106function bp_friends_random_members( $total_members = 5 ) {
    107107
    108         if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
     108        if ( !$user_ids = wp_cache_get( 'friends_random_users', bp_core_get_global_cache_key() ) ) {
    109109                $user_ids = BP_Core_User::get_users( 'random', $total_members );
    110                 wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
     110                wp_cache_set( 'friends_random_users', $user_ids, bp_core_get_global_cache_key() );
    111111        }
    112112
    113113        ?>
     
    441441
    442442                if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {
    443443                        $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() );
    444                         wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
     444                        wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, bp_core_get_global_cache_key() );
    445445                }
    446446
    447447                return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
     
    463463
    464464                if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {
    465465                        $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() );
    466                         wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
     466                        wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, bp_core_get_global_cache_key() );
    467467                }
    468468
    469469                return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) );
     
    485485
    486486                if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {
    487487                        $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() );
    488                         wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
     488                        wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, bp_core_get_global_cache_key() );
    489489                }
    490490
    491491                return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) );
  • content/plugins/buddypress/bp-groups/bp-groups-cache.php

    diff --git a/content/plugins/buddypress/bp-groups/bp-groups-cache.php b/content/plugins/buddypress/bp-groups/bp-groups-cache.php
    index 498cbee..3085644 100644
    a b  
    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        wp_cache_delete( 'bp_total_group_count', bp_core_get_global_cache_key() );
    5252}
    5353add_action( 'groups_group_deleted',              'groups_clear_group_object_cache' );
    5454add_action( 'groups_settings_updated',           'groups_clear_group_object_cache' );
     
    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        wp_cache_delete( 'bp_total_groups_for_user_' . $user_id, bp_core_get_global_cache_key() );
    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 );
  • content/plugins/buddypress/bp-groups/bp-groups-functions.php

    diff --git a/content/plugins/buddypress/bp-groups/bp-groups-functions.php b/content/plugins/buddypress/bp-groups/bp-groups-functions.php
    index c83e743..a4a8f2f 100644
    a b  
    629629 * @return int
    630630 */
    631631function groups_get_total_group_count() {
    632         if ( !$count = wp_cache_get( 'bp_total_group_count', 'bp' ) ) {
     632        if ( !$count = wp_cache_get( 'bp_total_group_count', bp_core_get_global_cache_key() ) ) {
    633633                $count = BP_Groups_Group::get_total_group_count();
    634                 wp_cache_set( 'bp_total_group_count', $count, 'bp' );
     634                wp_cache_set( 'bp_total_group_count', $count, bp_core_get_global_cache_key() );
    635635        }
    636636
    637637        return $count;
     
    669669        if ( empty( $user_id ) )
    670670                $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
    671671
    672         if ( !$count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' ) ) {
     672        if ( !$count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, bp_core_get_global_cache_key() ) ) {
    673673                $count = BP_Groups_Member::total_group_count( $user_id );
    674                 wp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, 'bp' );
     674                wp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, bp_core_get_global_cache_key() );
    675675        }
    676676
    677677        return $count;
  • content/plugins/buddypress/bp-members/bp-members-functions.php

    diff --git a/content/plugins/buddypress/bp-members/bp-members-functions.php b/content/plugins/buddypress/bp-members/bp-members-functions.php
    index 6a6de27..431d631 100644
    a b  
    182182                return false;
    183183        }
    184184
    185         if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {
     185        if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, bp_core_get_global_cache_key() ) ) {
    186186                $userdata = BP_Core_User::get_core_userdata( $user_id );
    187                 wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );
     187                wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, bp_core_get_global_cache_key() );
    188188        }
    189189        return apply_filters( 'bp_core_get_core_userdata', $userdata );
    190190}
     
    254254        $bp = buddypress();
    255255
    256256        // Check cache for user nicename
    257         $username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' );
     257        $username = wp_cache_get( 'bp_user_username_' . $user_id, bp_core_get_global_cache_key() );
    258258        if ( false === $username ) {
    259259
    260260                // Cache not found so prepare to update it
     
    303303
    304304        // Add this to cache
    305305        if ( ( true === $update_cache ) && !empty( $username ) ) {
    306                 wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );
     306                wp_cache_set( 'bp_user_username_' . $user_id, $username, bp_core_get_global_cache_key() );
    307307
    308308        // @todo bust this cache if no $username found?
    309309        //} else {
     
    329329function bp_members_get_user_nicename( $user_id ) {
    330330        $bp = buddypress();
    331331
    332         if ( !$user_nicename = wp_cache_get( 'bp_members_user_nicename_' . $user_id, 'bp' ) ) {
     332        if ( !$user_nicename = wp_cache_get( 'bp_members_user_nicename_' . $user_id, bp_core_get_global_cache_key() ) ) {
    333333                $update_cache = true;
    334334
    335335                // User ID matches logged in user
     
    364364
    365365        // Add this to cache
    366366        if ( true == $update_cache && !empty( $user_nicename ) ) {
    367                 wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );
     367                wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, bp_core_get_global_cache_key() );
    368368        }
    369369
    370370        return apply_filters( 'bp_members_get_user_nicename', $user_nicename );
     
    379379 */
    380380function bp_core_get_user_email( $uid ) {
    381381
    382         if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
     382        if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, bp_core_get_global_cache_key() ) ) {
    383383
    384384                // User exists
    385385                $ud = bp_core_get_core_userdata( $uid );
     
    391391                        $email = '';
    392392                }
    393393
    394                 wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
     394                wp_cache_set( 'bp_user_email_' . $uid, $email, bp_core_get_global_cache_key() );
    395395        }
    396396
    397397        return apply_filters( 'bp_core_get_user_email', $email );
     
    458458
    459459        $uncached_ids = array();
    460460        foreach ( $user_ids as $user_id ) {
    461                 if ( false === wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {
     461                if ( false === wp_cache_get( 'bp_user_fullname_' . $user_id, bp_core_get_global_cache_key() ) ) {
    462462                        $uncached_ids[] = $user_id;
    463463                }
    464464        }
     
    505505                }
    506506
    507507                foreach ( $fullnames as $fuser_id => $fname ) {
    508                         wp_cache_set( 'bp_user_fullname_' . $fuser_id, $fname, 'bp' );
     508                        wp_cache_set( 'bp_user_fullname_' . $fuser_id, $fname, bp_core_get_global_cache_key() );
    509509                }
    510510        }
    511511
    512512        $retval = array();
    513513        foreach ( $user_ids as $user_id ) {
    514                 $retval[ $user_id ] = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' );
     514                $retval[ $user_id ] = wp_cache_get( 'bp_user_fullname_' . $user_id, bp_core_get_global_cache_key() );
    515515        }
    516516
    517517        return $retval;
     
    597597function bp_core_get_total_member_count() {
    598598        global $wpdb;
    599599
    600         if ( !$count = wp_cache_get( 'bp_total_member_count', 'bp' ) ) {
     600        if ( !$count = wp_cache_get( 'bp_total_member_count', bp_core_get_global_cache_key() ) ) {
    601601                $status_sql = bp_core_get_status_sql();
    602602                $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}" );
    603                 wp_cache_set( 'bp_total_member_count', $count, 'bp' );
     603                wp_cache_set( 'bp_total_member_count', $count, bp_core_get_global_cache_key() );
    604604        }
    605605
    606606        return apply_filters( 'bp_core_get_total_member_count', $count );
  • content/plugins/buddypress/bp-settings/bp-settings-actions.php

    diff --git a/content/plugins/buddypress/bp-settings/bp-settings-actions.php b/content/plugins/buddypress/bp-settings/bp-settings-actions.php
    index cc99f7e..049f2fc 100644
    a b  
    196196                // Clear cached data, so that the changed settings take effect
    197197                // on the current page load
    198198                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                        wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), bp_core_get_global_cache_key() );
    200200                        $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
    201201                }
    202202
  • content/plugins/buddypress/bp-xprofile/bp-xprofile-cache.php

    diff --git a/content/plugins/buddypress/bp-xprofile/bp-xprofile-cache.php b/content/plugins/buddypress/bp-xprofile/bp-xprofile-cache.php
    index 0ad4103..5155a57 100644
    a b  
    121121}
    122122
    123123function 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' );
     124        wp_cache_delete( 'xprofile_groups_inc_empty',        bp_core_get_global_cache_key() );
     125        wp_cache_delete( 'xprofile_group_' . $group_obj->id, bp_core_get_global_cache_key() );
    126126}
    127127add_action( 'xprofile_group_after_delete', 'xprofile_clear_profile_groups_object_cache' );
    128128add_action( 'xprofile_group_after_save',   'xprofile_clear_profile_groups_object_cache' );
    129129
    130130function xprofile_clear_profile_data_object_cache( $group_id ) {
    131         wp_cache_delete( 'bp_user_fullname_' . bp_loggedin_user_id(), 'bp' );
     131        wp_cache_delete( 'bp_user_fullname_' . bp_loggedin_user_id(), bp_core_get_global_cache_key() );
    132132}
    133133add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache'   );
    134134
     
    142142 */
    143143function xprofile_clear_fullname_cache_on_profile_field_edit( $data ) {
    144144        if ( 1 == $data->field_id ) {
    145                 wp_cache_delete( 'bp_user_fullname_' . $data->user_id, 'bp' );
     145                wp_cache_delete( 'bp_user_fullname_' . $data->user_id, bp_core_get_global_cache_key() );
    146146        }
    147147}
    148148add_action( 'xprofile_data_after_save', 'xprofile_clear_fullname_cache_on_profile_field_edit' );
     
    156156 */
    157157function xprofile_clear_profile_field_object_cache( $field_obj ) {
    158158        // Clear default visibility level cache
    159         wp_cache_delete( 'xprofile_default_visibility_levels', 'bp' );
     159        wp_cache_delete( 'xprofile_default_visibility_levels', bp_core_get_global_cache_key() );
    160160
    161161        // Modified fields can alter parent group status, in particular when
    162162        // the group goes from empty to non-empty. Bust its cache, as well as
    163163        // 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' );
     164        wp_cache_delete( 'xprofile_group_' . $field_obj->group_id, bp_core_get_global_cache_key() );
     165        wp_cache_delete( 'xprofile_groups_inc_empty', bp_core_get_global_cache_key() );
    166166}
    167167add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' );
    168168add_action( 'xprofile_fields_deleted_field', 'xprofile_clear_profile_field_object_cache' );
  • content/plugins/buddypress/bp-xprofile/bp-xprofile-classes.php

    diff --git a/content/plugins/buddypress/bp-xprofile/bp-xprofile-classes.php b/content/plugins/buddypress/bp-xprofile/bp-xprofile-classes.php
    index 5fb8e50..0932cf2 100644
    a b  
    2626        public function populate( $id ) {
    2727                global $wpdb, $bp;
    2828
    29                 $group = wp_cache_get( 'xprofile_group_' . $this->id, 'bp' );
     29                $group = wp_cache_get( 'xprofile_group_' . $this->id, bp_core_get_global_cache_key() );
    3030
    3131                if ( false === $group ) {
    3232                        $group = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id ) );
     
    337337                foreach ( $group_ids as $group_id ) {
    338338
    339339                        // If cached data is found, use it
    340                         if ( $group_data = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
     340                        if ( $group_data = wp_cache_get( 'xprofile_group_' . $group_id, bp_core_get_global_cache_key() ) ) {
    341341                                $groups[ $group_id ] = $group_data;
    342342
    343343                        // Otherwise leave a placeholder so we don't lose the order
     
    362362                        // and add it to the cache
    363363                        foreach ( (array) $queried_gdata as $gdata ) {
    364364                                $groups[ $gdata->id ] = $gdata;
    365                                 wp_cache_set( 'xprofile_group_' . $gdata->id, $gdata, 'bp' );
     365                                wp_cache_set( 'xprofile_group_' . $gdata->id, $gdata, bp_core_get_global_cache_key() );
    366366                        }
    367367                }
    368368
     
    392392                }
    393393
    394394                // purge profile field group cache
    395                 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );
     395                wp_cache_delete( 'xprofile_groups_inc_empty', bp_core_get_global_cache_key() );
    396396
    397397                return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET group_order = %d WHERE id = %d", $position, $field_group_id ) );
    398398        }
     
    444444        public static function fetch_default_visibility_levels() {
    445445                global $wpdb, $bp;
    446446
    447                 $default_visibility_levels = wp_cache_get( 'xprofile_default_visibility_levels', 'bp' );
     447                $default_visibility_levels = wp_cache_get( 'xprofile_default_visibility_levels', bp_core_get_global_cache_key() );
    448448
    449449                if ( false === $default_visibility_levels ) {
    450450                        $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' )" );
     
    459459                                }
    460460                        }
    461461
    462                         wp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, 'bp' );
     462                        wp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, bp_core_get_global_cache_key() );
    463463                }
    464464
    465465                return $default_visibility_levels;
  • content/plugins/buddypress/bp-xprofile/bp-xprofile-template.php

    diff --git a/content/plugins/buddypress/bp-xprofile/bp-xprofile-template.php b/content/plugins/buddypress/bp-xprofile/bp-xprofile-template.php
    index 5c9e53f..c93d97e 100644
    a b  
    627627 * @return object $groups
    628628 */
    629629function bp_profile_get_field_groups() {
    630         $groups = wp_cache_get( 'xprofile_groups_inc_empty', 'bp' );
     630        $groups = wp_cache_get( 'xprofile_groups_inc_empty', bp_core_get_global_cache_key() );
    631631
    632632        if ( empty( $groups ) ) {
    633633                $groups = bp_xprofile_get_groups( array( 'fetch_fields' => true ) );
    634                 wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );
     634                wp_cache_set( 'xprofile_groups_inc_empty', $groups, bp_core_get_global_cache_key() );
    635635        }
    636636
    637637        return apply_filters( 'bp_profile_get_field_groups', $groups );
     
    696696                if ( !is_numeric( $group_id ) )
    697697                        $group_id = 1;
    698698
    699                 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
     699                if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, bp_core_get_global_cache_key() ) ) {
    700700                        $group = new BP_XProfile_Group($group_id);
    701                         wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' );
     701                        wp_cache_set( 'xprofile_group_' . $group_id, $group, bp_core_get_global_cache_key() );
    702702                }
    703703
    704704                return apply_filters( 'bp_get_profile_group_name', $group->name );