Changeset 9676 for trunk/src/bp-xprofile/bp-xprofile-cache.php
- Timestamp:
- 04/01/2015 11:14:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-cache.php
r9351 r9676 53 53 * object type ('group', 'field', 'data') 54 54 */ 55 function bp_xprofile_update_meta_cache( $object_ids = array() , $user_id = 0) {55 function bp_xprofile_update_meta_cache( $object_ids = array() ) { 56 56 global $wpdb; 57 57 … … 76 76 foreach ( $uncached_object_ids as $object_type => $uncached_object_type_ids ) { 77 77 if ( ! empty( $object_ids[ $object_type ] ) ) { 78 78 79 // Sanitize $object_ids passed to the function 79 80 $object_type_ids = wp_parse_id_list( $object_ids[ $object_type ] ); … … 90 91 91 92 // If there are uncached items, go ahead with the query 92 if ( $do_query ) {93 if ( true === $do_query ) { 93 94 $where = array(); 94 95 foreach ( $uncached_object_ids as $otype => $oids ) { … … 139 140 } 140 141 142 /** 143 * Clear cached XProfile field group data 144 * 145 * @since BuddyPress (2.1.0) 146 * 147 * @param object $group_obj 148 */ 141 149 function xprofile_clear_profile_groups_object_cache( $group_obj ) { 142 wp_cache_delete( ' xprofile_groups_inc_empty', 'bp' );143 wp_cache_delete( 'xprofile_group_' . $group_obj->id, 'bp' );150 wp_cache_delete( 'all', 'bp_xprofile_groups' ); 151 wp_cache_delete( $group_obj->id, 'bp_xprofile_groups' ); 144 152 } 145 153 add_action( 'xprofile_group_after_delete', 'xprofile_clear_profile_groups_object_cache' ); 146 154 add_action( 'xprofile_group_after_save', 'xprofile_clear_profile_groups_object_cache' ); 147 155 148 function xprofile_clear_profile_data_object_cache( $group_id ) { 149 wp_cache_delete( 'bp_user_fullname_' . bp_loggedin_user_id(), 'bp' ); 150 } 151 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 156 /** 157 * Clear cached XProfile fullname data for user 158 * 159 * @since BuddyPress (2.1.0) 160 * 161 * @param int $user_id ID of user whose fullname cache to delete 162 */ 163 function xprofile_clear_profile_data_object_cache( $user_id = 0 ) { 164 wp_cache_delete( 'bp_user_fullname_' . $user_id, 'bp' ); 165 } 166 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 152 167 153 168 /** … … 174 189 */ 175 190 function xprofile_clear_profile_field_object_cache( $field_obj ) { 191 176 192 // Clear default visibility level cache 177 wp_cache_delete( ' xprofile_default_visibility_levels', 'bp' );193 wp_cache_delete( 'default_visibility_levels', 'bp_xprofile' ); 178 194 179 195 // Modified fields can alter parent group status, in particular when 180 196 // the group goes from empty to non-empty. Bust its cache, as well as 181 // the global group_inc_emptycache182 wp_cache_delete( ' xprofile_group_' . $field_obj->group_id, 'bp' );183 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );184 } 185 add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' );197 // the global 'all' cache 198 wp_cache_delete( 'all', 'bp_xprofile_groups' ); 199 wp_cache_delete( $field_obj->group_id, 'bp_xprofile_groups' ); 200 } 201 add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' ); 186 202 add_action( 'xprofile_fields_deleted_field', 'xprofile_clear_profile_field_object_cache' ); 187 203
Note: See TracChangeset
for help on using the changeset viewer.