Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/14/2014 12:37:28 AM (11 years ago)
Author:
boonebgorges
Message:

Return an empty string from get_meta() functions when no value is found

BP get_meta() functions have been inconsistent about the type of value returned
when no match is found for the object_id+meta_key combination. In some cases,
we followed WP's get_metadata() and returned an empty string. In others, we
returned false.

This changeset aligns all of our get_meta() functions with WP in this regard,
returning an empty string when no matching value is found. A boolean false is
still returned when invalid arguments are passed to the functions.

Relevant unit tests have been updated, including strict assertSame() checking
where appropriate.

See #5399

File:
1 edited

Legend:

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

    r8129 r8131  
    308308    public function test_groups_update_groupmeta_new() {
    309309        $g = $this->factory->group->create();
    310         $this->assertEquals( '', groups_get_groupmeta( $g, 'foo' ), '"foo" meta should be empty for this group.' );
     310        $this->assertSame( '', groups_get_groupmeta( $g, 'foo' ), '"foo" meta should be empty for this group.' );
    311311        $this->assertTrue( groups_update_groupmeta( $g, 'foo', 'bar' ) );
    312312        $this->assertSame( 'bar', groups_get_groupmeta( $g, 'foo' ) );
     
    365365
    366366        $krazy_key = ' f!@#$%^o *(){}o?+';
    367         $this->assertEmpty( groups_get_groupmeta( $g, $krazy_key ) );
     367        $this->assertSame( '', groups_get_groupmeta( $g, $krazy_key ) );
    368368    }
    369369
     
    509509
    510510        $this->assertTrue( groups_delete_groupmeta( $g1, 'foo', '', true ) );
    511         $this->assertEmpty( '', groups_get_groupmeta( $g1, 'foo' ) );
    512         $this->assertEmpty( '', groups_get_groupmeta( $g2, 'foo' ) );
     511        $this->assertSame( '', groups_get_groupmeta( $g1, 'foo' ) );
     512        $this->assertSame( '', groups_get_groupmeta( $g2, 'foo' ) );
    513513        $this->assertSame( 'bar1', groups_get_groupmeta( $g1, 'foo1' ) );
    514514        $this->assertSame( 'bar1', groups_get_groupmeta( $g2, 'foo1' ) );
Note: See TracChangeset for help on using the changeset viewer.