Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/17/2014 12:35:26 AM (13 years ago)
Author:
boonebgorges
Message:

Don't prime groupmeta cache in BP_Groups_Group::construct()

groups_get_groupmeta() 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 groupmeta
when instantiating BP_Groups_Group, 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/groups/functions.php

    r7887 r7903  
    438438        /**
    439439         * @group groupmeta
     440         * @group groups_get_groupmeta
     441         * @group cache
     442         */
     443        public function test_groups_get_groupmeta_cache_all_on_get() {
     444                $g = $this->factory->group->create();
     445                groups_add_groupmeta( $g, 'foo', 'bar' );
     446                groups_add_groupmeta( $g, 'foo1', 'baz' );
     447                $this->assertFalse( wp_cache_get( $g, 'group_meta' ) );
     448
     449                // A single query should prime the whole meta cache
     450                groups_get_groupmeta( $g, 'foo' );
     451
     452                $c = wp_cache_get( $g, 'group_meta' );
     453                $this->assertNotEmpty( $c['foo1'] );
     454        }
     455
     456        /**
     457         * @group groupmeta
    440458         */
    441459        public function test_groups_delete_groupmeta_non_numeric_id() {
Note: See TracChangeset for help on using the changeset viewer.