Skip to:
Content

BuddyPress.org

Changeset 8130


Ignore:
Timestamp:
03/14/2014 12:15:41 AM (10 years ago)
Author:
boonebgorges
Message:

Don't trim whitespace from $meta_value param in _delete_meta() functions

The $meta_value parameter of BP's delete_meta() functions allows developers to
limit deletion to rows that match both the $meta_key *and* the specified
$meta_value. However, most of BP's delete_meta() functions have always had a
quirk whereby the $meta_value was run through trim() before matching against
the values in the database. This had the unacceptable side effect that passing
a $meta_value of ' foo ' would delete rows with the value 'foo', but *not*
the value ' foo '!

This changeset reverses the behavior, and modifies the relevant unit tests.

See #5399

Location:
trunk
Files:
6 edited

Legend:

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

    r8129 r8130  
    576576        return false;
    577577    }
    578 
    579     // Legacy - Trim off whitespace
    580     $meta_value = trim( $meta_value );
    581578
    582579    // Legacy - if no meta_key is passed, delete all for the item
  • trunk/bp-blogs/bp-blogs-functions.php

    r8129 r8130  
    862862    }
    863863
    864     // Legacy - trim meta_value
    865     $meta_value = trim( $meta_value );
    866 
    867864    add_filter( 'query', 'bp_filter_metaid_column_name' );
    868865
  • trunk/bp-xprofile/bp-xprofile-functions.php

    r8129 r8130  
    601601    }
    602602
    603     // Legacy - trim meta_value
    604     $meta_value = trim( $meta_value );
    605 
    606603    add_filter( 'query', 'bp_filter_metaid_column_name' );
    607604    add_filter( 'query', 'bp_xprofile_filter_meta_query' );
  • trunk/tests/testcases/activity/functions.php

    r8129 r8130  
    330330     * @group activitymeta
    331331     * @group bp_activity_delete_meta
     332     * @ticket BP5399
    332333     */
    333334    public function test_bp_activity_delete_meta_trim_meta_value() {
    334         // @todo Wtf?
    335335        $a = $this->factory->activity->create();
    336336        bp_activity_update_meta( $a, 'foo', 'bar' );
    337         $this->assertTrue( bp_activity_delete_meta( $a, 'foo', ' bar ' ) );
    338         $this->assertFalse( bp_activity_get_meta( $a, 'foo' ) );
     337        bp_activity_delete_meta( $a, 'foo', ' bar ' );
     338        $this->assertSame( 'bar', bp_activity_get_meta( $a, 'foo' ) );
    339339    }
    340340
  • trunk/tests/testcases/blogs/functions.php

    r8129 r8130  
    2929     * @group blogmeta
    3030     * @group bp_blogs_delete_blogmeta
     31     * @ticket BP5399
    3132     */
    3233    public function test_bp_blogs_delete_blogmeta_trim_meta_value() {
    3334        $this->assertTrue( bp_blogs_update_blogmeta( 1, 'foo', 'bar' ) );
    3435        $this->assertSame( 'bar', bp_blogs_get_blogmeta( 1, 'foo' ) );
    35         $this->assertTrue( bp_blogs_delete_blogmeta( 1, 'foo', '   bar  ') );
    36         $this->assertSame( '', bp_blogs_get_blogmeta( 1, 'foo' ) );
     36        bp_blogs_delete_blogmeta( 1, 'foo', '   bar  ' );
     37        $this->assertSame( 'bar', bp_blogs_get_blogmeta( 1, 'foo' ) );
    3738    }
    3839
  • trunk/tests/testcases/xprofile/functions.php

    r8129 r8130  
    201201     * @group xprofilemeta
    202202     * @group bp_xprofile_delete_meta
     203     * @ticket BP5399
    203204     */
    204205    public function test_bp_xprofile_delete_meta_trim_meta_value() {
     
    207208        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    208209
    209         $this->assertTrue( bp_xprofile_delete_meta( $g, 'group', 'foo', ' bar  ' ) );
    210         $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     210        bp_xprofile_delete_meta( $g, 'group', 'foo', ' bar  ' );
     211        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    211212    }
    212213
Note: See TracChangeset for help on using the changeset viewer.