Changeset 13971 for trunk/src/bp-groups/bp-groups-cache.php
- Timestamp:
- 07/23/2024 01:32:42 AM (23 months ago)
- File:
-
- 1 edited
-
trunk/src/bp-groups/bp-groups-cache.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-cache.php
r13890 r13971 3 3 * BuddyPress Groups Caching. 4 4 * 5 * Caching functions handle the clearing of cached objects and pages on specific6 * actions throughout BuddyPress.7 *8 5 * @package BuddyPress 9 * @subpackage Groups 6 * @subpackage GroupsCache 10 7 * @since 1.5.0 11 8 */ … … 35 32 36 33 $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, 39 36 'cache_group' => 'group_meta', 40 37 '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', 43 40 ); 44 41 … … 56 53 wp_cache_delete( 'bp_total_group_count', 'bp' ); 57 54 } 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' );55 add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' ); 56 add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' ); 57 add_action( 'groups_details_updated', 'groups_clear_group_object_cache' ); 58 add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' ); 62 59 add_action( 'groups_create_group_step_complete', 'groups_clear_group_object_cache' ); 63 60 … … 72 69 wp_cache_delete( $group_id, 'bp_groups' ); 73 70 } 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' );71 add_action( 'groups_delete_group', 'bp_groups_delete_group_cache' ); 72 add_action( 'groups_update_group', 'bp_groups_delete_group_cache' ); 73 add_action( 'groups_details_updated', 'bp_groups_delete_group_cache' ); 77 74 add_action( 'groups_settings_updated', 'bp_groups_delete_group_cache' ); 78 75 … … 115 112 function bp_groups_clear_group_members_caches( $group_obj, $user_ids ) { 116 113 // 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 ) { 118 115 groups_clear_group_user_object_cache( $group_obj->id, $user_id ); 116 } 119 117 } 120 118 add_action( 'bp_groups_delete_group', 'bp_groups_clear_group_members_caches', 10, 2 ); … … 123 121 * Clear a user's cached total group invite count. 124 122 * 125 * Count is cleared when an invit eis accepted, rejected or deleted.123 * Count is cleared when an invitation is accepted, rejected or deleted. 126 124 * 127 125 * @since 2.0.0 … … 177 175 wp_cache_delete( 'bp_total_groups_for_user_' . $user_id, 'bp' ); 178 176 } 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 );177 add_action( 'groups_join_group', 'groups_clear_group_user_object_cache', 10, 2 ); 178 add_action( 'groups_leave_group', 'groups_clear_group_user_object_cache', 10, 2 ); 179 add_action( 'groups_ban_member', 'groups_clear_group_user_object_cache', 10, 2 ); 180 add_action( 'groups_unban_member', 'groups_clear_group_user_object_cache', 10, 2 ); 183 181 add_action( 'groups_uninvite_user', 'groups_clear_group_user_object_cache', 10, 2 ); 184 182 add_action( 'groups_remove_member', 'groups_clear_group_user_object_cache', 10, 2 ); … … 196 194 } 197 195 add_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' );196 add_action( 'groups_demote_member', 'groups_clear_group_administrator_cache' ); 197 add_action( 'groups_delete_group', 'groups_clear_group_administrator_cache' ); 200 198 201 199 /** … … 265 263 * @since 5.0.0 266 264 * 267 * @param BP_Invitation object$invitation Characteristics of the invitation just saved.265 * @param BP_Invitation $invitation Characteristics of the invitation just saved. 268 266 */ 269 267 function bp_groups_clear_user_group_cache_on_invitation_save( BP_Invitation $invitation ) { … … 274 272 wp_cache_delete( $invitation->id, 'bp_groups_invitations_as_memberships' ); 275 273 } 276 add_action( 'bp_invitation_after_save', 'bp_groups_clear_user_group_cache_on_invitation_save' , 10, 2);274 add_action( 'bp_invitation_after_save', 'bp_groups_clear_user_group_cache_on_invitation_save' ); 277 275 278 276 /** … … 285 283 */ 286 284 function bp_groups_clear_user_group_cache_on_invitation_change( $args ) { 287 $args['fields' ]= 'ids';285 $args['fields'] = 'ids'; 288 286 $affected_invitation_ids = groups_get_invites( $args ); 289 287 foreach ( $affected_invitation_ids as $invitation_id ) { … … 320 318 * 321 319 * @since 2.7.0 322 *323 * @return bool324 320 */ 325 321 function bp_groups_reset_cache_incrementor() { 326 returnbp_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 } 324 add_action( 'groups_group_after_save', 'bp_groups_reset_cache_incrementor' ); 325 add_action( 'bp_groups_delete_group', 'bp_groups_reset_cache_incrementor' ); 326 add_action( 'updated_group_meta', 'bp_groups_reset_cache_incrementor' ); 327 add_action( 'deleted_group_meta', 'bp_groups_reset_cache_incrementor' ); 328 add_action( 'added_group_meta', 'bp_groups_reset_cache_incrementor' ); 333 329 add_action( 'groups_member_after_remove', 'bp_groups_reset_cache_incrementor' ); 334 330 … … 345 341 * @param array $tt_ids Array of term taxonomy IDs. 346 342 * @param string $taxonomy Taxonomy slug. 347 * @return bool348 343 */ 349 344 function bp_groups_reset_cache_incrementor_on_group_term_change( $object_id, $terms, $tt_ids, $taxonomy ) { 350 345 $tax_object = get_taxonomy( $taxonomy ); 351 346 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 } 356 349 } 357 350 add_action( 'bp_set_object_terms', 'bp_groups_reset_cache_incrementor_on_group_term_change', 10, 4 ); … … 368 361 * @param array $terms Array of object terms. 369 362 * @param string $taxonomy Taxonomy slug. 370 * @return bool371 363 */ 372 364 function bp_groups_reset_cache_incrementor_on_group_term_remove( $object_id, $terms, $taxonomy ) { 373 365 $tax_object = get_taxonomy( $taxonomy ); 374 366 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 } 379 369 } 380 370 add_action( 'bp_remove_object_terms', 'bp_groups_reset_cache_incrementor_on_group_term_remove', 10, 3 ); 381 371 382 372 /* 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' );373 add_action( 'groups_join_group', 'bp_core_clear_cache' ); 374 add_action( 'groups_leave_group', 'bp_core_clear_cache' ); 375 add_action( 'groups_accept_invite', 'bp_core_clear_cache' ); 376 add_action( 'groups_reject_invite', 'bp_core_clear_cache' ); 377 add_action( 'groups_invite_user', 'bp_core_clear_cache' ); 378 add_action( 'groups_uninvite_user', 'bp_core_clear_cache' ); 379 add_action( 'groups_details_updated', 'bp_core_clear_cache' ); 380 add_action( 'groups_settings_updated', 'bp_core_clear_cache' ); 381 add_action( 'groups_unban_member', 'bp_core_clear_cache' ); 382 add_action( 'groups_ban_member', 'bp_core_clear_cache' ); 383 add_action( 'groups_demote_member', 'bp_core_clear_cache' ); 384 add_action( 'groups_promote_member', 'bp_core_clear_cache' ); 385 add_action( 'groups_membership_rejected', 'bp_core_clear_cache' ); 386 add_action( 'groups_membership_accepted', 'bp_core_clear_cache' ); 387 add_action( 'groups_membership_requested', 'bp_core_clear_cache' ); 398 388 add_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' );389 add_action( 'groups_created_group', 'bp_core_clear_cache' ); 390 add_action( 'groups_group_avatar_updated', 'bp_core_clear_cache' );
Note: See TracChangeset
for help on using the changeset viewer.