Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/16/2014 11:51:32 PM (11 years ago)
Author:
boonebgorges
Message:

Don't prime activitymeta cache in BP_Activity_Activity::construct()

bp_activity_get_meta() now uses the core API functions. get_metadata() works by
priming the cache with *all* object metadata when requesting any piece of
metadata for that object. This means that, instead of pre-fetching activitymeta
when instantiating BP_Activity_Activity, we wait until it happens in
get_metadata(). At best, this can help us to avoid pre-fetching a meta cache
that will not be used.

See #5398

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/functions.php

    r7887 r7901  
    298298        bp_activity_add_meta( $a, 'foo', 'baz' );
    299299        $this->assertSame( array( 'bar', 'baz' ), bp_activity_get_meta( $a, 'foo', false ) );
     300    }
     301
     302    /**
     303     * @group activitymeta
     304     * @group bp_activity_get_meta
     305     * @group cache
     306     */
     307    public function test_bp_activity_get_meta_cache_all_on_get() {
     308        $a = $this->factory->activity->create();
     309        bp_activity_add_meta( $a, 'foo', 'bar' );
     310        bp_activity_add_meta( $a, 'foo1', 'baz' );
     311        $this->assertFalse( wp_cache_get( $a, 'activity_meta' ) );
     312
     313        // A single query should prime the whole meta cache
     314        bp_activity_get_meta( $a, 'foo' );
     315
     316        $c = wp_cache_get( $a, 'activity_meta' );
     317        $this->assertNotEmpty( $c['foo1'] );
    300318    }
    301319
Note: See TracChangeset for help on using the changeset viewer.