Return false from metadata_exists() if the get_$type_metadata filter returns a false value.
props xknown. fixes #22746. git-svn-id: https://develop.svn.wordpress.org/trunk@27562 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
adf2b46b8e
commit
681ca37c63
@ -323,7 +323,7 @@ function metadata_exists( $meta_type, $object_id, $meta_key ) {
|
||||
|
||||
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true );
|
||||
if ( null !== $check )
|
||||
return true;
|
||||
return (bool) $check;
|
||||
|
||||
$meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' );
|
||||
|
||||
|
@ -83,6 +83,17 @@ class Tests_Meta extends WP_UnitTestCase {
|
||||
$this->assertFalse( metadata_exists( 'user', 1234567890, 'meta_key' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 22746
|
||||
*/
|
||||
function test_metadata_exists_with_filter() {
|
||||
// Let's see if it returns the correct value when adding a filter.
|
||||
add_filter( 'get_user_metadata', '__return_zero' );
|
||||
$this->assertFalse( metadata_exists( 'user', $this->author->ID, 'meta_key' ) ); // existing meta key
|
||||
$this->assertFalse( metadata_exists( 'user', 1234567890, 'meta_key' ) );
|
||||
remove_filter( 'get_user_metadata', '__return_zero' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 18158
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user