Changeset 13092 for trunk/src/bp-friends/bp-friends-cache.php
- Timestamp:
- 08/24/2021 04:16:17 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-cache.php
r11949 r13092 24 24 */ 25 25 function friends_clear_friend_object_cache( $friendship_id ) { 26 if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) ) 26 $friendship = new BP_Friends_Friendship( $friendship_id ); 27 if ( ! $friendship ) { 27 28 return false; 29 } 28 30 29 wp_cache_delete( 'friends_friend_ids_' . 30 wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id,'bp' );31 wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' ); 32 wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' ); 31 33 } 32 34 33 35 // List actions to clear object caches on. 34 36 add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' ); 35 add_action( 'friends_friendship_deleted', 37 add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' ); 36 38 37 39 /** … … 43 45 * @param int $initiator_user_id ID of the first user. 44 46 * @param int $friend_user_id ID of the second user. 45 * @return bool46 47 */ 47 48 function bp_friends_clear_bp_friends_friendships_cache( $friendship_id, $initiator_user_id, $friend_user_id ) { 48 49 // Clear friendship ID cache for each user. 49 50 wp_cache_delete( $initiator_user_id, 'bp_friends_friendships_for_user' ); 50 wp_cache_delete( $friend_user_id, 51 wp_cache_delete( $friend_user_id, 'bp_friends_friendships_for_user' ); 51 52 52 53 // Clear the friendship object cache. … … 60 61 } 61 62 add_action( 'friends_friendship_requested', 'bp_friends_clear_bp_friends_friendships_cache', 10, 3 ); 62 add_action( 'friends_friendship_accepted', 63 add_action( 'friends_friendship_deleted', 63 add_action( 'friends_friendship_accepted', 'bp_friends_clear_bp_friends_friendships_cache', 10, 3 ); 64 add_action( 'friends_friendship_deleted', 'bp_friends_clear_bp_friends_friendships_cache', 10, 3 ); 64 65 65 66 /** … … 69 70 * 70 71 * @param int $friendship_id The friendship ID. 71 * @param BP_Friends_Friendship $friendship Friendship object.72 * @param BP_Friends_Friendship $friendship The friendship object. 72 73 */ 73 function bp_friends_clear_bp_friends_friendships_cache_remove( $friendship_id, BP_Friends_Friendship$friendship ) {74 function bp_friends_clear_bp_friends_friendships_cache_remove( $friendship_id, $friendship ) { 74 75 // Clear friendship ID cache for each user. 75 76 wp_cache_delete( $friendship->initiator_user_id, 'bp_friends_friendships_for_user' ); 76 wp_cache_delete( $friendship->friend_user_id, 77 wp_cache_delete( $friendship->friend_user_id, 'bp_friends_friendships_for_user' ); 77 78 78 79 // Clear the friendship object cache. … … 83 84 } 84 85 add_action( 'friends_friendship_withdrawn', 'bp_friends_clear_bp_friends_friendships_cache_remove', 10, 2 ); 85 add_action( 'friends_friendship_rejected', 86 add_action( 'friends_friendship_rejected', 'bp_friends_clear_bp_friends_friendships_cache_remove', 10, 2 ); 86 87 87 88 /** … … 111 112 } 112 113 add_action( 'friends_friendship_requested', 'bp_friends_clear_request_cache_on_save', 10, 3 ); 113 add_action( 'friends_friendship_accepted', 114 add_action( 'friends_friendship_accepted', 'bp_friends_clear_request_cache_on_save', 10, 3 ); 114 115 115 116 /** … … 121 122 * 122 123 * @param int $friendship_id The friendship ID. 123 * @param BP_Friends_Friendship $friendship Friendship object.124 * @param BP_Friends_Friendship $friendship The friendship object. 124 125 */ 125 function bp_friends_clear_request_cache_on_remove( $friendship_id, BP_Friends_Friendship$friendship ) {126 function bp_friends_clear_request_cache_on_remove( $friendship_id, $friendship ) { 126 127 bp_friends_clear_request_cache( $friendship->friend_user_id ); 127 128 } 128 129 add_action( 'friends_friendship_withdrawn', 'bp_friends_clear_request_cache_on_remove', 10, 2 ); 129 add_action( 'friends_friendship_rejected', 130 add_action( 'friends_friendship_rejected', 'bp_friends_clear_request_cache_on_remove', 10, 2 ); 130 131 131 132 /** … … 134 135 * @since 3.0.0 135 136 * 136 * @param BP_Friends_Friendship $friendship Friendship object.137 * @param BP_Friends_Friendship $friendship The friendship object. 137 138 */ 138 139 function bp_friends_delete_cached_friendships_on_friendship_save( $friendship ) {
Note: See TracChangeset
for help on using the changeset viewer.