WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/17/2014 07:39:31 PM (7 years ago)
Author:
nacin
Message:

Return false from metadata_exists() if the get_$type_metadata filter returns a false value.

props xknown.
fixes #22746.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/meta.php

    r26307 r27562  
    8282        $this->assertFalse( metadata_exists( 'user',  1234567890, 'foobarbaz' ) );
    8383        $this->assertFalse( metadata_exists( 'user',  1234567890, 'meta_key' ) );
     84    }
     85
     86    /**
     87     * @ticket 22746
     88     */
     89    function test_metadata_exists_with_filter() {
     90        // Let's see if it returns the correct value when adding a filter.
     91        add_filter( 'get_user_metadata', '__return_zero' );
     92        $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'meta_key' ) ); // existing meta key
     93        $this->assertFalse( metadata_exists( 'user', 1234567890, 'meta_key' ) );
     94        remove_filter( 'get_user_metadata', '__return_zero' );
    8495    }
    8596
Note: See TracChangeset for help on using the changeset viewer.