Skip to:
Content

BuddyPress.org

Changeset 7997


Ignore:
Timestamp:
02/27/2014 07:48:22 PM (10 years ago)
Author:
r-a-y
Message:

Properly set object cache for a new BP_Activity_Activity object.

This commit also renames the activity cache key and group to be
consistent with the groups component. (See r7956.)

See #5434.

Location:
trunk/bp-activity
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-cache.php

    r7907 r7997  
    4343 */
    4444function bp_activity_clear_cache_for_activity( $activity ) {
    45     wp_cache_delete( 'activity_' . $activity->id, 'bp' );
     45    wp_cache_delete( $activity->id, 'bp_activity' );
    4646}
    4747add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
     
    5656function bp_activity_clear_cache_for_deleted_activity( $deleted_ids ) {
    5757    foreach ( (array) $deleted_ids as $deleted_id ) {
    58         wp_cache_delete( 'activity_' . $deleted_id, 'bp' );
     58        wp_cache_delete( $deleted_id, 'bp_activity' );
    5959    }
    6060}
  • trunk/bp-activity/bp-activity-classes.php

    r7959 r7997  
    138138        global $wpdb, $bp;
    139139
    140         $row = wp_cache_get( 'activity_' . $this->id, 'bp' );
     140        $row = wp_cache_get( $this->id, 'bp_activity' );
    141141
    142142        if ( false === $row ) {
    143143            $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
     144
     145            wp_cache_set( $this->id, $row, 'bp_activity' );
    144146        }
    145147
     
    475477
    476478            // If cached data is found, use it
    477             if ( $activity_data = wp_cache_get( 'activity_' . $activity_id, 'bp' ) ) {
     479            if ( $activity_data = wp_cache_get( $activity_id, 'bp_activity' ) ) {
    478480                $activities[ $activity_id ] = $activity_data;
    479481
     
    499501            foreach ( (array) $queried_adata as $adata ) {
    500502                $activities[ $adata->id ] = $adata;
    501                 wp_cache_set( 'activity_' . $adata->id, $adata, 'bp' );
     503                wp_cache_set( $adata->id, $adata, 'bp_activity' );
    502504            }
    503505        }
Note: See TracChangeset for help on using the changeset viewer.