Changeset 7843
- Timestamp:
- 02/11/2014 04:51:43 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-cache.php
r7821 r7843 180 180 'object_ids' => array(), // Comma-separated list or array of item ids 181 181 'object_type' => '', // Canonical component id: groups, members, etc 182 'cache_group' => '', // Cache group 182 183 'meta_table' => '', // Name of the table containing the metadata 183 184 'object_column' => '', // DB column for the object ids (group_id, etc) … … 188 189 extract( $r ); 189 190 190 if ( empty( $object_ids ) || empty( $object_type ) || empty( $meta_table ) ) {191 if ( empty( $object_ids ) || empty( $object_type ) || empty( $meta_table ) || empty( $cache_group ) ) { 191 192 return false; 192 193 } … … 200 201 } 201 202 202 $object_ids = wp_parse_id_list( $object_ids ); 203 if ( ! $cache_group ) { 204 return false; 205 } 206 207 $object_ids = wp_parse_id_list( $object_ids ); 208 $uncached_ids = bp_get_non_cached_ids( $object_ids, $cache_group ); 203 209 204 210 $cache = array(); 205 211 206 212 // Get meta info 207 $id_list = join( ',', $object_ids ); 208 $meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT {$object_column}, meta_key, meta_value FROM {$meta_table} WHERE {$object_column} IN ($id_list)", $object_type ), ARRAY_A ); 209 210 if ( !empty( $meta_list ) ) { 211 foreach ( $meta_list as $metarow ) { 212 $mpid = intval( $metarow[$object_column] ); 213 $mkey = $metarow['meta_key']; 214 $mval = $metarow['meta_value']; 215 216 // Force subkeys to be array type: 217 if ( !isset( $cache[$mpid] ) || !is_array( $cache[$mpid] ) ) 218 $cache[$mpid] = array(); 219 if ( !isset( $cache[$mpid][$mkey] ) || !is_array( $cache[$mpid][$mkey] ) ) 220 $cache[$mpid][$mkey] = array(); 221 222 // Add a value to the current pid/key: 223 $cache[$mpid][$mkey][] = $mval; 213 if ( ! empty( $uncached_ids ) ) { 214 $id_list = join( ',', $object_ids ); 215 $meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT {$object_column}, meta_key, meta_value FROM {$meta_table} WHERE {$object_column} IN ($id_list)", $object_type ), ARRAY_A ); 216 217 if ( ! empty( $meta_list ) ) { 218 foreach ( $meta_list as $metarow ) { 219 $mpid = intval( $metarow[$object_column] ); 220 $mkey = $metarow['meta_key']; 221 $mval = $metarow['meta_value']; 222 223 // Force subkeys to be array type: 224 if ( !isset( $cache[$mpid] ) || !is_array( $cache[$mpid] ) ) 225 $cache[$mpid] = array(); 226 if ( !isset( $cache[$mpid][$mkey] ) || !is_array( $cache[$mpid][$mkey] ) ) 227 $cache[$mpid][$mkey] = array(); 228 229 // Add a value to the current pid/key: 230 $cache[$mpid][$mkey][] = $mval; 231 } 224 232 } 225 } 226 227 foreach ( $object_ids as $id ) { 228 if ( ! isset($cache[$id]) ) 229 $cache[$id] = array(); 230 231 foreach( $cache[$id] as $meta_key => $meta_value ) { 232 wp_cache_set( $cache_key_prefix . '_' . $id . '_' . $meta_key, $meta_value, 'bp' ); 233 234 foreach ( $cache as $object_id => $cache_val ) { 235 wp_cache_set( $object_id, $cache_val, $cache_group ); 233 236 } 234 237 } -
trunk/bp-groups/bp-groups-cache.php
r7645 r7843 34 34 'object_ids' => $group_ids, 35 35 'object_type' => $bp->groups->id, 36 'cache_group' => 'group_meta', 36 37 'object_column' => 'group_id', 37 38 'meta_table' => $bp->groups->table_name_groupmeta,
Note: See TracChangeset
for help on using the changeset viewer.