Skip to:
Content

BuddyPress.org

Changeset 5612


Ignore:
Timestamp:
12/30/2011 04:16:45 PM (12 years ago)
Author:
boonebgorges
Message:

Cache all activity meta when bp_activity_get_meta() is called without a meta_key. Fixes #3872

File:
1 edited

Legend:

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

    r5546 r5612  
    534534    // No key so get all for activity_id
    535535    } else {
    536         $metas = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
    537     }
    538 
     536        $metas = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
     537               
     538        if ( !empty( $metas ) ) {
     539            $metas = array_map( 'maybe_unserialize', (array)$metas );
     540           
     541            foreach( $metas as $mkey => $mvalue ) {
     542                wp_cache_set( 'bp_activity_meta_' . $activity_id . '_' . $mkey, $mvalue, 'bp' );
     543            }
     544        }
     545    }
     546   
    539547    // No result so return false
    540548    if ( empty( $metas ) )
Note: See TracChangeset for help on using the changeset viewer.