Skip to:
Content

BuddyPress.org

Changeset 13971


Ignore:
Timestamp:
07/23/2024 01:32:42 AM (8 months ago)
Author:
espellcaste
Message:

WPCS: miscellaneous fixes for cache-related files in several components.

See #9174 and #9173
Closes https://github.com/buddypress/buddypress/pull/331

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-cache.php

    r13890 r13971  
    11<?php
    22/**
    3  * Functions related to the BuddyPress Activity component and the WP Cache.
     3 * BuddyPress Activity Caching.
    44 *
    55 * @package BuddyPress
     
    2727
    2828    $cache_args = array(
    29         'object_ids'       => $activity_ids,
    30         'object_type'      => $bp->activity->id,
     29        'object_ids'       => $activity_ids,
     30        'object_type'      => $bp->activity->id,
    3131        'object_column'    => 'activity_id',
    3232        'cache_group'      => 'activity_meta',
    33         'meta_table'       => $bp->activity->table_name_meta,
    34         'cache_key_prefix' => 'bp_activity_meta'
     33        'meta_table'       => $bp->activity->table_name_meta,
     34        'cache_key_prefix' => 'bp_activity_meta',
    3535    );
    3636
     
    8585    return $without_last_activity && $with_last_activity;
    8686}
    87 add_action( 'bp_activity_delete',    'bp_activity_reset_cache_incrementor' );
    88 add_action( 'bp_activity_add',       'bp_activity_reset_cache_incrementor' );
    89 add_action( 'added_activity_meta',   'bp_activity_reset_cache_incrementor' );
     87add_action( 'bp_activity_delete', 'bp_activity_reset_cache_incrementor' );
     88add_action( 'bp_activity_add', 'bp_activity_reset_cache_incrementor' );
     89add_action( 'added_activity_meta', 'bp_activity_reset_cache_incrementor' );
    9090add_action( 'updated_activity_meta', 'bp_activity_reset_cache_incrementor' );
    9191add_action( 'deleted_activity_meta', 'bp_activity_reset_cache_incrementor' );
  • trunk/src/bp-blogs/bp-blogs-cache.php

    r12606 r13971  
    22/**
    33 * BuddyPress Blogs Caching.
    4  *
    5  * Caching functions handle the clearing of cached objects and pages on specific
    6  * actions throughout BuddyPress.
    74 *
    85 * @package BuddyPress
     
    3532    bp_update_meta_cache( $cache_args );
    3633}
     34
    3735/**
    3836 * Clear the blog object cache.
     
    4543function bp_blogs_clear_blog_object_cache( $blog_id = 0, $user_id = 0 ) {
    4644    if ( ! empty( $user_id ) ) {
    47         wp_cache_delete( 'bp_blogs_of_user_'        . $user_id, 'bp' );
     45        wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
    4846        wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
    4947    }
     
    5452// List actions to clear object caches on.
    5553add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
    56 add_action( 'bp_insert_site',                'bp_blogs_clear_blog_object_cache', 10, 2 );
    57 add_action( 'bp_blogs_remove_blog',          'bp_blogs_clear_blog_object_cache' );
     54add_action( 'bp_insert_site', 'bp_blogs_clear_blog_object_cache', 10, 2 );
     55add_action( 'bp_blogs_remove_blog', 'bp_blogs_clear_blog_object_cache' );
    5856
    5957// List actions to clear super cached pages on, if super cache is installed.
    6058add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
    61 add_action( 'bp_blogs_remove_comment',       'bp_core_clear_cache' );
    62 add_action( 'bp_blogs_remove_post',          'bp_core_clear_cache' );
     59add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' );
     60add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' );
    6361add_action( 'bp_blogs_remove_blog_for_user', 'bp_core_clear_cache' );
    64 add_action( 'bp_blogs_remove_blog',          'bp_core_clear_cache' );
    65 add_action( 'bp_blogs_new_blog_comment',     'bp_core_clear_cache' );
    66 add_action( 'bp_blogs_new_blog_post',        'bp_core_clear_cache' );
    67 add_action( 'bp_blogs_new_blog',             'bp_core_clear_cache' );
    68 add_action( 'bp_blogs_remove_data',          'bp_core_clear_cache' );
     62add_action( 'bp_blogs_remove_blog', 'bp_core_clear_cache' );
     63add_action( 'bp_blogs_new_blog_comment', 'bp_core_clear_cache' );
     64add_action( 'bp_blogs_new_blog_post', 'bp_core_clear_cache' );
     65add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' );
     66add_action( 'bp_blogs_remove_data', 'bp_core_clear_cache' );
  • trunk/src/bp-core/bp-core-cache.php

    r13904 r13971  
    11<?php
    22/**
    3  * BuddyPress Core Caching Functions.
    4  *
    5  * Caching functions handle the clearing of cached objects and pages on specific
    6  * actions throughout BuddyPress.
     3 * BuddyPress Core Caching.
    74 *
    85 * @package BuddyPress
    9  * @subpackage Cache
     6 * @subpackage Core
    107 * @since 1.5.0
    118 */
  • trunk/src/bp-friends/bp-friends-cache.php

    r13092 r13971  
    33 * BuddyPress Friends Caching.
    44 *
    5  * Caching functions handle the clearing of cached objects and pages on specific
    6  * actions throughout BuddyPress.
    7  *
    85 * @package BuddyPress
    9  * @subpackage FriendsCaching
     6 * @subpackage FriendsCache
    107 * @since 1.5.0
    118 */
     
    2118 * @param int $friendship_id ID of the friendship whose two members should
    2219 *                           have their friends cache busted.
    23  * @return bool
    2420 */
    2521function friends_clear_friend_object_cache( $friendship_id ) {
    2622    $friendship = new BP_Friends_Friendship( $friendship_id );
    27     if ( ! $friendship ) {
    28         return false;
     23
     24    if ( empty( $friendship->id ) ) {
     25        return;
    2926    }
    3027
     
    5552
    5653    // Clear incremented cache.
    57     $friendship = new stdClass;
     54    $friendship                    = new stdClass();
    5855    $friendship->initiator_user_id = $initiator_user_id;
    5956    $friendship->friend_user_id    = $friend_user_id;
     
    135132 * @since 3.0.0
    136133 *
    137  * @param BP_Friends_Friendship $friendship The friendship object.
     134 * @param BP_Friends_Friendship|stdClass $friendship The friendship object.
    138135 */
    139136function bp_friends_delete_cached_friendships_on_friendship_save( $friendship ) {
     
    144141
    145142// List actions to clear super cached pages on, if super cache is installed.
    146 add_action( 'friends_friendship_rejected',  'bp_core_clear_cache' );
    147 add_action( 'friends_friendship_accepted',  'bp_core_clear_cache' );
    148 add_action( 'friends_friendship_deleted',   'bp_core_clear_cache' );
     143add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' );
     144add_action( 'friends_friendship_accepted', 'bp_core_clear_cache' );
     145add_action( 'friends_friendship_deleted', 'bp_core_clear_cache' );
    149146add_action( 'friends_friendship_requested', 'bp_core_clear_cache' );
  • trunk/src/bp-groups/bp-groups-cache.php

    r13890 r13971  
    33 * BuddyPress Groups Caching.
    44 *
    5  * Caching functions handle the clearing of cached objects and pages on specific
    6  * actions throughout BuddyPress.
    7  *
    85 * @package BuddyPress
    9  * @subpackage Groups
     6 * @subpackage GroupsCache
    107 * @since 1.5.0
    118 */
     
    3532
    3633    $cache_args = array(
    37         'object_ids'       => $group_ids,
    38         'object_type'      => $bp->groups->id,
     34        'object_ids'       => $group_ids,
     35        'object_type'      => $bp->groups->id,
    3936        'cache_group'      => 'group_meta',
    4037        'object_column'    => 'group_id',
    41         'meta_table'       => $bp->groups->table_name_groupmeta,
    42         'cache_key_prefix' => 'bp_groups_groupmeta'
     38        'meta_table'       => $bp->groups->table_name_groupmeta,
     39        'cache_key_prefix' => 'bp_groups_groupmeta',
    4340    );
    4441
     
    5653    wp_cache_delete( 'bp_total_group_count', 'bp' );
    5754}
    58 add_action( 'groups_group_deleted',              'groups_clear_group_object_cache' );
    59 add_action( 'groups_settings_updated',           'groups_clear_group_object_cache' );
    60 add_action( 'groups_details_updated',            'groups_clear_group_object_cache' );
    61 add_action( 'groups_group_avatar_updated',       'groups_clear_group_object_cache' );
     55add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' );
     56add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' );
     57add_action( 'groups_details_updated', 'groups_clear_group_object_cache' );
     58add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' );
    6259add_action( 'groups_create_group_step_complete', 'groups_clear_group_object_cache' );
    6360
     
    7269    wp_cache_delete( $group_id, 'bp_groups' );
    7370}
    74 add_action( 'groups_delete_group',     'bp_groups_delete_group_cache' );
    75 add_action( 'groups_update_group',     'bp_groups_delete_group_cache' );
    76 add_action( 'groups_details_updated',  'bp_groups_delete_group_cache' );
     71add_action( 'groups_delete_group', 'bp_groups_delete_group_cache' );
     72add_action( 'groups_update_group', 'bp_groups_delete_group_cache' );
     73add_action( 'groups_details_updated', 'bp_groups_delete_group_cache' );
    7774add_action( 'groups_settings_updated', 'bp_groups_delete_group_cache' );
    7875
     
    115112function bp_groups_clear_group_members_caches( $group_obj, $user_ids ) {
    116113    // Clears the 'total groups' cache for each member in a group.
    117     foreach ( (array) $user_ids as $user_id )
     114    foreach ( (array) $user_ids as $user_id ) {
    118115        groups_clear_group_user_object_cache( $group_obj->id, $user_id );
     116    }
    119117}
    120118add_action( 'bp_groups_delete_group', 'bp_groups_clear_group_members_caches', 10, 2 );
     
    123121 * Clear a user's cached total group invite count.
    124122 *
    125  * Count is cleared when an invite is accepted, rejected or deleted.
     123 * Count is cleared when an invitation is accepted, rejected or deleted.
    126124 *
    127125 * @since 2.0.0
     
    177175    wp_cache_delete( 'bp_total_groups_for_user_' . $user_id, 'bp' );
    178176}
    179 add_action( 'groups_join_group',    'groups_clear_group_user_object_cache', 10, 2 );
    180 add_action( 'groups_leave_group',   'groups_clear_group_user_object_cache', 10, 2 );
    181 add_action( 'groups_ban_member',    'groups_clear_group_user_object_cache', 10, 2 );
    182 add_action( 'groups_unban_member',  'groups_clear_group_user_object_cache', 10, 2 );
     177add_action( 'groups_join_group', 'groups_clear_group_user_object_cache', 10, 2 );
     178add_action( 'groups_leave_group', 'groups_clear_group_user_object_cache', 10, 2 );
     179add_action( 'groups_ban_member', 'groups_clear_group_user_object_cache', 10, 2 );
     180add_action( 'groups_unban_member', 'groups_clear_group_user_object_cache', 10, 2 );
    183181add_action( 'groups_uninvite_user', 'groups_clear_group_user_object_cache', 10, 2 );
    184182add_action( 'groups_remove_member', 'groups_clear_group_user_object_cache', 10, 2 );
     
    196194}
    197195add_action( 'groups_promote_member', 'groups_clear_group_administrator_cache' );
    198 add_action( 'groups_demote_member',  'groups_clear_group_administrator_cache' );
    199 add_action( 'groups_delete_group',   'groups_clear_group_administrator_cache' );
     196add_action( 'groups_demote_member', 'groups_clear_group_administrator_cache' );
     197add_action( 'groups_delete_group', 'groups_clear_group_administrator_cache' );
    200198
    201199/**
     
    265263 * @since 5.0.0
    266264 *
    267  * @param BP_Invitation object $invitation Characteristics of the invitation just saved.
     265 * @param BP_Invitation $invitation Characteristics of the invitation just saved.
    268266 */
    269267function bp_groups_clear_user_group_cache_on_invitation_save( BP_Invitation $invitation ) {
     
    274272    wp_cache_delete( $invitation->id, 'bp_groups_invitations_as_memberships' );
    275273}
    276 add_action( 'bp_invitation_after_save', 'bp_groups_clear_user_group_cache_on_invitation_save', 10, 2 );
     274add_action( 'bp_invitation_after_save', 'bp_groups_clear_user_group_cache_on_invitation_save' );
    277275
    278276/**
     
    285283 */
    286284function bp_groups_clear_user_group_cache_on_invitation_change( $args ) {
    287     $args['fields' ] = 'ids';
     285    $args['fields']          = 'ids';
    288286    $affected_invitation_ids = groups_get_invites( $args );
    289287    foreach ( $affected_invitation_ids as $invitation_id ) {
     
    320318 *
    321319 * @since 2.7.0
    322  *
    323  * @return bool
    324320 */
    325321function bp_groups_reset_cache_incrementor() {
    326     return bp_core_reset_incrementor( 'bp_groups' );
    327 }
    328 add_action( 'groups_group_after_save',    'bp_groups_reset_cache_incrementor' );
    329 add_action( 'bp_groups_delete_group',     'bp_groups_reset_cache_incrementor' );
    330 add_action( 'updated_group_meta',         'bp_groups_reset_cache_incrementor' );
    331 add_action( 'deleted_group_meta',         'bp_groups_reset_cache_incrementor' );
    332 add_action( 'added_group_meta',           'bp_groups_reset_cache_incrementor' );
     322    bp_core_reset_incrementor( 'bp_groups' );
     323}
     324add_action( 'groups_group_after_save', 'bp_groups_reset_cache_incrementor' );
     325add_action( 'bp_groups_delete_group', 'bp_groups_reset_cache_incrementor' );
     326add_action( 'updated_group_meta', 'bp_groups_reset_cache_incrementor' );
     327add_action( 'deleted_group_meta', 'bp_groups_reset_cache_incrementor' );
     328add_action( 'added_group_meta', 'bp_groups_reset_cache_incrementor' );
    333329add_action( 'groups_member_after_remove', 'bp_groups_reset_cache_incrementor' );
    334330
     
    345341 * @param array  $tt_ids    Array of term taxonomy IDs.
    346342 * @param string $taxonomy  Taxonomy slug.
    347  * @return bool
    348343 */
    349344function bp_groups_reset_cache_incrementor_on_group_term_change( $object_id, $terms, $tt_ids, $taxonomy ) {
    350345    $tax_object = get_taxonomy( $taxonomy );
    351346    if ( $tax_object && in_array( 'bp_group', $tax_object->object_type, true ) ) {
    352         return bp_groups_reset_cache_incrementor();
    353     }
    354 
    355     return false;
     347        bp_groups_reset_cache_incrementor();
     348    }
    356349}
    357350add_action( 'bp_set_object_terms', 'bp_groups_reset_cache_incrementor_on_group_term_change', 10, 4 );
     
    368361 * @param array  $terms     Array of object terms.
    369362 * @param string $taxonomy  Taxonomy slug.
    370  * @return bool
    371363 */
    372364function bp_groups_reset_cache_incrementor_on_group_term_remove( $object_id, $terms, $taxonomy ) {
    373365    $tax_object = get_taxonomy( $taxonomy );
    374366    if ( $tax_object && in_array( 'bp_group', $tax_object->object_type, true ) ) {
    375         return bp_groups_reset_cache_incrementor();
    376     }
    377 
    378     return false;
     367        bp_groups_reset_cache_incrementor();
     368    }
    379369}
    380370add_action( 'bp_remove_object_terms', 'bp_groups_reset_cache_incrementor_on_group_term_remove', 10, 3 );
    381371
    382372/* List actions to clear super cached pages on, if super cache is installed */
    383 add_action( 'groups_join_group',                 'bp_core_clear_cache' );
    384 add_action( 'groups_leave_group',                'bp_core_clear_cache' );
    385 add_action( 'groups_accept_invite',              'bp_core_clear_cache' );
    386 add_action( 'groups_reject_invite',              'bp_core_clear_cache' );
    387 add_action( 'groups_invite_user',                'bp_core_clear_cache' );
    388 add_action( 'groups_uninvite_user',              'bp_core_clear_cache' );
    389 add_action( 'groups_details_updated',            'bp_core_clear_cache' );
    390 add_action( 'groups_settings_updated',           'bp_core_clear_cache' );
    391 add_action( 'groups_unban_member',               'bp_core_clear_cache' );
    392 add_action( 'groups_ban_member',                 'bp_core_clear_cache' );
    393 add_action( 'groups_demote_member',              'bp_core_clear_cache' );
    394 add_action( 'groups_promote_member',             'bp_core_clear_cache' );
    395 add_action( 'groups_membership_rejected',        'bp_core_clear_cache' );
    396 add_action( 'groups_membership_accepted',        'bp_core_clear_cache' );
    397 add_action( 'groups_membership_requested',       'bp_core_clear_cache' );
     373add_action( 'groups_join_group', 'bp_core_clear_cache' );
     374add_action( 'groups_leave_group', 'bp_core_clear_cache' );
     375add_action( 'groups_accept_invite', 'bp_core_clear_cache' );
     376add_action( 'groups_reject_invite', 'bp_core_clear_cache' );
     377add_action( 'groups_invite_user', 'bp_core_clear_cache' );
     378add_action( 'groups_uninvite_user', 'bp_core_clear_cache' );
     379add_action( 'groups_details_updated', 'bp_core_clear_cache' );
     380add_action( 'groups_settings_updated', 'bp_core_clear_cache' );
     381add_action( 'groups_unban_member', 'bp_core_clear_cache' );
     382add_action( 'groups_ban_member', 'bp_core_clear_cache' );
     383add_action( 'groups_demote_member', 'bp_core_clear_cache' );
     384add_action( 'groups_promote_member', 'bp_core_clear_cache' );
     385add_action( 'groups_membership_rejected', 'bp_core_clear_cache' );
     386add_action( 'groups_membership_accepted', 'bp_core_clear_cache' );
     387add_action( 'groups_membership_requested', 'bp_core_clear_cache' );
    398388add_action( 'groups_create_group_step_complete', 'bp_core_clear_cache' );
    399 add_action( 'groups_created_group',              'bp_core_clear_cache' );
    400 add_action( 'groups_group_avatar_updated',       'bp_core_clear_cache' );
     389add_action( 'groups_created_group', 'bp_core_clear_cache' );
     390add_action( 'groups_group_avatar_updated', 'bp_core_clear_cache' );
  • trunk/src/bp-members/bp-members-cache.php

    r13890 r13971  
    11<?php
    22/**
    3  * Caching functions specific to BuddyPress Members.
     3 * BuddyPress Members Caching.
    44 *
    55 * @package BuddyPress
     
    2121    $uncached_member_ids = bp_get_non_cached_ids( $bp_user_query->user_ids, 'bp_member_member_type' );
    2222
    23     $member_types = bp_get_object_terms( $uncached_member_ids, bp_get_member_type_tax_name(), array(
    24         'fields' => 'all_with_object_id',
    25     ) );
     23    $member_types = bp_get_object_terms(
     24        $uncached_member_ids,
     25        bp_get_member_type_tax_name(),
     26        array(
     27            'fields' => 'all_with_object_id',
     28        )
     29    );
    2630
    2731    // Rekey by user ID.
     
    6771 *
    6872 * @since 2.7.0
    69  *
    70  * @return bool
    7173 */
    7274function bp_members_reset_activity_cache_incrementor() {
    73     return bp_core_reset_incrementor( 'bp_activity_with_last_activity' );
     75    bp_core_reset_incrementor( 'bp_activity_with_last_activity' );
    7476}
    7577add_action( 'bp_core_user_updated_last_activity', 'bp_members_reset_activity_cache_incrementor' );
     
    8587    wp_cache_delete( $signup_id, 'bp_signups' );
    8688}
    87 add_action( 'bp_core_signups_after_add',         'bp_members_delete_signup_cache' );
     89add_action( 'bp_core_signups_after_add', 'bp_members_delete_signup_cache' );
    8890add_action( 'bp_core_signups_after_update_meta', 'bp_members_delete_signup_cache' );
    8991
     
    102104    }
    103105}
    104 add_action( 'bp_core_signup_after_resend',   'bp_members_delete_signup_cache_multiples' );
     106add_action( 'bp_core_signup_after_resend', 'bp_members_delete_signup_cache_multiples' );
    105107add_action( 'bp_core_signup_after_activate', 'bp_members_delete_signup_cache_multiples' );
    106 add_action( 'bp_core_signup_after_delete',   'bp_members_delete_signup_cache_multiples' );
     108add_action( 'bp_core_signup_after_delete', 'bp_members_delete_signup_cache_multiples' );
    107109
    108110/**
     
    115117 *
    116118 * @since 10.0.0
    117  *
    118  * @return bool
    119119 */
    120120function bp_members_reset_signup_cache_incrementor() {
    121     return bp_core_reset_incrementor( 'bp_signups' );
     121    bp_core_reset_incrementor( 'bp_signups' );
    122122}
    123 add_filter( 'bp_core_signups_after_add',         'bp_members_reset_signup_cache_incrementor' );
    124 add_action( 'bp_core_activated_user',            'bp_members_reset_signup_cache_incrementor' );
    125 add_action( 'bp_core_signup_after_activate',     'bp_members_reset_signup_cache_incrementor' );
     123add_filter( 'bp_core_signups_after_add', 'bp_members_reset_signup_cache_incrementor' );
     124add_action( 'bp_core_activated_user', 'bp_members_reset_signup_cache_incrementor' );
     125add_action( 'bp_core_signup_after_activate', 'bp_members_reset_signup_cache_incrementor' );
    126126add_action( 'bp_core_signups_after_update_meta', 'bp_members_reset_signup_cache_incrementor' );
    127 add_action( 'bp_core_signup_after_delete',       'bp_members_reset_signup_cache_incrementor' );
    128 
     127add_action( 'bp_core_signup_after_delete', 'bp_members_reset_signup_cache_incrementor' );
  • trunk/src/bp-messages/bp-messages-cache.php

    r13402 r13971  
    22/**
    33 * BuddyPress Messages Caching.
    4  *
    5  * Caching functions handle the clearing of cached objects and pages on specific
    6  * actions throughout BuddyPress.
    74 *
    85 * @package BuddyPress
     
    2724 */
    2825function bp_messages_update_meta_cache( $message_ids = false ) {
    29     bp_update_meta_cache( array(
    30         'object_ids'       => $message_ids,
    31         'object_type'      => buddypress()->messages->id,
    32         'cache_group'      => 'message_meta',
    33         'object_column'    => 'message_id',
    34         'meta_table'       => buddypress()->messages->table_name_meta,
    35         'cache_key_prefix' => 'bp_messages_meta'
    36     ) );
     26    bp_update_meta_cache(
     27        array(
     28            'object_ids'       => $message_ids,
     29            'object_type'      => buddypress()->messages->id,
     30            'cache_group'      => 'message_meta',
     31            'object_column'    => 'message_id',
     32            'meta_table'       => buddypress()->messages->table_name_meta,
     33            'cache_key_prefix' => 'bp_messages_meta',
     34        )
     35    );
    3736}
    3837
    3938// List actions to clear super cached pages on, if super cache is installed.
    40 add_action( 'messages_delete_thread',  'bp_core_clear_cache' );
    41 add_action( 'messages_send_notice',    'bp_core_clear_cache' );
    42 add_action( 'messages_message_sent',   'bp_core_clear_cache' );
     39add_action( 'messages_delete_thread', 'bp_core_clear_cache' );
     40add_action( 'messages_send_notice', 'bp_core_clear_cache' );
     41add_action( 'messages_message_sent', 'bp_core_clear_cache' );
    4342
    4443// Don't cache message inbox/sentbox/compose as it's too problematic.
    4544add_action( 'messages_screen_compose', 'bp_core_clear_cache' );
    4645add_action( 'messages_screen_sentbox', 'bp_core_clear_cache' );
    47 add_action( 'messages_screen_inbox',   'bp_core_clear_cache' );
     46add_action( 'messages_screen_inbox', 'bp_core_clear_cache' );
    4847
    4948/**
     
    105104 * Invalidate cache for notices.
    106105 *
    107  * Currently, invalidates active notice cache.
    108  *
    109106 * @since 2.0.0
    110107 */
  • trunk/src/bp-notifications/bp-notifications-cache.php

    r13247 r13971  
    11<?php
    22/**
    3  * Functions related to notifications caching.
     3 * BuddyPress Notifications Caching.
    44 *
    55 * @package BuddyPress
     
    2525 */
    2626function bp_notifications_update_meta_cache( $notification_ids = false ) {
    27     bp_update_meta_cache( array(
    28         'object_ids'       => $notification_ids,
    29         'object_type'      => buddypress()->notifications->id,
    30         'cache_group'      => 'notification_meta',
    31         'object_column'    => 'notification_id',
    32         'meta_table'       => buddypress()->notifications->table_name_meta,
    33         'cache_key_prefix' => 'bp_notifications_meta',
    34     ) );
     27    bp_update_meta_cache(
     28        array(
     29            'object_ids'       => $notification_ids,
     30            'object_type'      => buddypress()->notifications->id,
     31            'cache_group'      => 'notification_meta',
     32            'object_column'    => 'notification_id',
     33            'meta_table'       => buddypress()->notifications->table_name_meta,
     34            'cache_key_prefix' => 'bp_notifications_meta',
     35        )
     36    );
    3537}
    3638
     
    98100        bp_notifications_clear_all_for_user_cache( $where_args['user_id'] );
    99101
    100     // Get user ID from Notification ID.
     102        // Get user ID from Notification ID.
    101103    } elseif ( ! empty( $where_args['id'] ) ) {
    102104        $n = bp_notifications_get_notification( $where_args['id'] );
     
    114116        $ns = BP_Notifications_Notification::get(
    115117            array(
    116                 'id'      => $ids,
    117                 'is_new'  => $is_new,
     118                'id'     => $ids,
     119                'is_new' => $is_new,
    118120            )
    119121        );
  • trunk/src/bp-xprofile/bp-xprofile-cache.php

    r13491 r13971  
    22/**
    33 * BuddyPress XProfile Caching Functions.
    4  *
    5  * Caching functions handle the clearing of cached objects and pages on specific
    6  * actions throughout BuddyPress.
    74 *
    85 * @package BuddyPress
     
    5552 * @param array $object_ids Multi-dimensional array of object_ids, keyed by
    5653 *                          object type ('group', 'field', 'data').
    57  * @return bool
    5854 */
    5955function bp_xprofile_update_meta_cache( $object_ids = array() ) {
     
    6258    // Bail if no objects.
    6359    if ( empty( $object_ids ) ) {
    64         return false;
     60        return;
    6561    }
    6662
     
    132128
    133129    // Setup the WHERE query part.
    134     $where_sql = implode( " OR ", $where_conditions );
     130    $where_sql = implode( ' OR ', $where_conditions );
    135131
    136132    // Attempt to query meta values.
     
    186182 */
    187183function xprofile_clear_profile_groups_object_cache( $group_obj ) {
    188     wp_cache_delete( 'all',          'bp_xprofile_groups' );
     184    wp_cache_delete( 'all', 'bp_xprofile_groups' );
    189185    wp_cache_delete( $group_obj->id, 'bp_xprofile_groups' );
    190186}
    191187add_action( 'xprofile_group_after_delete', 'xprofile_clear_profile_groups_object_cache' );
    192 add_action( 'xprofile_group_after_save',   'xprofile_clear_profile_groups_object_cache' );
     188add_action( 'xprofile_group_after_save', 'xprofile_clear_profile_groups_object_cache' );
    193189
    194190/**
     
    207203    // the group goes from empty to non-empty. Bust its cache, as well as
    208204    // the global 'all' cache.
    209     wp_cache_delete( 'all',                'bp_xprofile_groups' );
     205    wp_cache_delete( 'all', 'bp_xprofile_groups' );
    210206    wp_cache_delete( $field_obj->group_id, 'bp_xprofile_groups' );
    211207}
    212 add_action( 'xprofile_fields_saved_field',   'xprofile_clear_profile_field_object_cache' );
     208add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' );
    213209add_action( 'xprofile_fields_deleted_field', 'xprofile_clear_profile_field_object_cache' );
    214210
     
    233229    wp_cache_delete( "{$data_obj->user_id}:{$data_obj->field_id}", 'bp_xprofile_data' );
    234230}
    235 add_action( 'xprofile_data_after_save',   'xprofile_clear_profiledata_object_cache' );
     231add_action( 'xprofile_data_after_save', 'xprofile_clear_profiledata_object_cache' );
    236232add_action( 'xprofile_data_after_delete', 'xprofile_clear_profiledata_object_cache' );
    237233
     
    262258 *
    263259 * @param int|BP_XProfile_Field $field A field ID or a field object.
    264  * @return bool False on failure.
    265260 */
    266261function bp_xprofile_clear_field_cache( $field ) {
     
    272267
    273268    if ( ! isset( $field_id ) ) {
    274         return false;
     269        return;
    275270    }
    276271
     
    316311    wp_cache_delete( $user_id, 'bp_user_mid' );
    317312}
    318 add_action( 'profile_update', 'bp_xprofile_reset_user_mid_cache', 10, 1 );
     313add_action( 'profile_update', 'bp_xprofile_reset_user_mid_cache' );
    319314
    320315/**
Note: See TracChangeset for help on using the changeset viewer.