Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/14/2014 12:37:28 AM (10 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/xprofile/functions.php

    r8130 r8131  
    221221        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    222222        $this->assertTrue( bp_xprofile_delete_meta( $g, 'group', 'foo', 'bar' ) );
    223         $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     223        $this->assertSame( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    224224    }
    225225
     
    237237        $this->assertTrue( bp_xprofile_delete_meta( $g, 'group' ) );
    238238
    239         $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    240         $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo2' ) );
     239        $this->assertSame( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     240        $this->assertSame( '', bp_xprofile_get_meta( $g, 'group', 'foo2' ) );
    241241    }
    242242
     
    276276
    277277        $this->assertTrue( bp_xprofile_delete_meta( $g1, 'group', 'foo', '', true ) );
    278         $this->assertEmpty( '', bp_xprofile_get_meta( $g1, 'group', 'foo' ) );
    279         $this->assertEmpty( '', bp_xprofile_get_meta( $g2, 'group', 'foo' ) );
     278        $this->assertSame( '', bp_xprofile_get_meta( $g1, 'group', 'foo' ) );
     279        $this->assertSame( '', bp_xprofile_get_meta( $g2, 'group', 'foo' ) );
    280280        $this->assertSame( 'bar1', bp_xprofile_get_meta( $g1, 'group', 'foo1' ) );
    281281        $this->assertSame( 'bar1', bp_xprofile_get_meta( $g2, 'group', 'foo1' ) );
     
    386386        $krazy_key = ' f!@#$%^o *(){}o?+';
    387387        bp_xprofile_update_meta( $g, 'group', $krazy_key, 'bar' );
    388         $this->assertEmpty( bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     388        $this->assertSame( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    389389    }
    390390
Note: See TracChangeset for help on using the changeset viewer.