Skip to:
Content

BuddyPress.org

Changeset 7901


Ignore:
Timestamp:
02/16/2014 11:51:32 PM (13 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

Location:
trunk
Files:
2 edited

Legend:

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

    r7860 r7901  
    159159                        $this->mptt_right        = $row->mptt_right;
    160160                        $this->is_spam           = $row->is_spam;
    161 
    162                         bp_activity_update_meta_cache( $this->id );
    163161                }
    164162        }
  • 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.