Changeset 9336 for trunk/src/bp-xprofile/bp-xprofile-classes.php
- Timestamp:
- 01/09/2015 08:38:37 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-classes.php
r9329 r9336 1223 1223 global $wpdb, $bp; 1224 1224 1225 $cache_ group = 'bp_xprofile_data_' . $user_id;1226 $profiledata = wp_cache_get( $ field_id, $cache_group);1225 $cache_key = "{$user_id}:{$field_id}"; 1226 $profiledata = wp_cache_get( $cache_key, 'bp_xprofile_data' ); 1227 1227 1228 1228 if ( false === $profiledata ) { 1229 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id );1229 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ); 1230 1230 $profiledata = $wpdb->get_row( $sql ); 1231 1231 1232 1232 if ( $profiledata ) { 1233 wp_cache_set( $ field_id, $profiledata, $cache_group);1233 wp_cache_set( $cache_key, $profiledata, 'bp_xprofile_data' ); 1234 1234 } 1235 1235 } … … 1260 1260 1261 1261 // Check cache first 1262 $cached = wp_cache_get( $this->field_id, 'bp_xprofile_data_' . $this->user_id ); 1262 $cache_key = "{$this->user_id}:{$this->field_id}"; 1263 $cached = wp_cache_get( $cache_key, 'bp_xprofile_data' ); 1263 1264 1264 1265 if ( $cached && ! empty( $cached->id ) ) { … … 1401 1402 $data = array(); 1402 1403 1403 $cache_group = 'bp_xprofile_data_' . $user_id; 1404 1405 $uncached_field_ids = bp_get_non_cached_ids( $field_ids, $cache_group ); 1404 $uncached_field_ids = bp_xprofile_get_non_cached_field_ids( $user_id, $field_ids, 'bp_xprofile_data' ); 1406 1405 1407 1406 // Prime the cache … … 1427 1426 foreach ( $uncached_field_ids as $field_id ) { 1428 1427 1428 $cache_key = "{$user_id}:{$field_id}"; 1429 1429 1430 // If a value was found, cache it 1430 1431 if ( isset( $queried_data[ $field_id ] ) ) { 1431 wp_cache_set( $ field_id, $queried_data[ $field_id ], $cache_group);1432 wp_cache_set( $cache_key, $queried_data[ $field_id ], 'bp_xprofile_data' ); 1432 1433 1433 1434 // If no value was found, cache an empty item … … 1441 1442 $d->last_updated = ''; 1442 1443 1443 wp_cache_set( $ field_id, $d, $cache_group);1444 wp_cache_set( $cache_key, $d, 'bp_xprofile_data' ); 1444 1445 } 1445 1446 } … … 1448 1449 // Now that all items are cached, fetch them 1449 1450 foreach ( $field_ids as $field_id ) { 1450 $data[] = wp_cache_get( $field_id, $cache_group ); 1451 $cache_key = "{$user_id}:{$field_id}"; 1452 $data[] = wp_cache_get( $cache_key, 'bp_xprofile_data' ); 1451 1453 } 1452 1454 … … 1461 1463 */ 1462 1464 public static function get_all_for_user( $user_id ) { 1463 global $wpdb, $bp;1464 1465 1465 1466 $groups = bp_xprofile_get_groups( array( … … 1515 1516 1516 1517 // Check cache first 1517 $fielddata = wp_cache_get( $field_id, 'bp_xprofile_data_' . $user_id ); 1518 $cache_key = "{$user_id}:{$field_id}"; 1519 $fielddata = wp_cache_get( $cache_key, 'bp_xprofile_data' ); 1518 1520 if ( false === $fielddata || empty( $fielddata->id ) ) { 1519 1521 $fielddata_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ) ); … … 1552 1554 $uncached_ids = array(); 1553 1555 foreach ( $user_ids as $user_id ) { 1554 if ( false === wp_cache_get( $field_id, 'bp_xprofile_data_' . $user_id ) ) { 1556 $cache_key = "{$user_id}:{$field_id}"; 1557 if ( false === wp_cache_get( $cache_key, 'bp_xprofile_data' ) ) { 1555 1558 $uncached_ids[] = $user_id; 1556 1559 } … … 1584 1587 } 1585 1588 1586 wp_cache_set( $field_id, $d, 'bp_xprofile_data_' . $d->user_id ); 1589 $cache_key = "{$d->user_id}:{$field_id}"; 1590 wp_cache_set( $cache_key, $d, 'bp_xprofile_data' ); 1587 1591 } 1588 1592 } … … 1591 1595 $data = array(); 1592 1596 foreach ( $user_ids as $user_id ) { 1593 $data[] = wp_cache_get( $field_id, 'bp_xprofile_data_' . $user_id ); 1597 $cache_key = "{$user_id}:{$field_id}"; 1598 $data[] = wp_cache_get( $cache_key, 'bp_xprofile_data' ); 1594 1599 } 1595 1600
Note: See TracChangeset
for help on using the changeset viewer.