Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/14/2014 01:04:58 AM (11 years ago)
Author:
boonebgorges
Message:

Use WP's array format for get_meta() functions when no $meta_key is provided

Passing only an object_id to a get_meta() function in WP will return an array
of arrays, keyed by meta_keys, each containing a list of meta_values for that
meta_key. BP's get_meta() functions were inconsistent in this regard: some
returned arrays of stdClass, some returned one-d arrays of meta_values. All
returned values that were practically of little use, because they didn't have
enough information about the located data to make it useful.

This changeset aligns BP's get_meta() functions with WP's. We now allow the
return value of get_metadata() to pass through untouched in all cases. Unit
tests have been updated as necessary.

See #5399

File:
1 edited

Legend:

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

    r8132 r8133  
    8383
    8484        // test if activity meta entries still exist
    85         $this->assertEquals( false, $m1 );
    86         $this->assertEquals( false, $m2 );
    87         $this->assertEquals( false, $m3 );
     85        $this->assertEmpty( $m1 );
     86        $this->assertEmpty( $m2 );
     87        $this->assertEmpty( $m3 );
    8888    }
    8989
     
    251251        bp_activity_update_meta( $a, 'foo1', 'bar1' );
    252252
    253         $am1 = new stdClass;
    254         $am1->meta_key = 'foo';
    255         $am1->meta_value = 'bar';
    256 
    257         $am2 = new stdClass;
    258         $am2->meta_key = 'foo1';
    259         $am2->meta_value = 'bar1';
    260 
    261253        $expected = array(
    262             $am1,
    263             $am2,
     254            'foo' => array(
     255                'bar',
     256            ),
     257            'foo1' => array(
     258                'bar1',
     259            ),
    264260        );
    265261
Note: See TracChangeset for help on using the changeset viewer.