Opened 16 months ago
Last modified 14 months ago
#58993 new defect (bug)
metadata_exists() returns incorrect value when "get_{$meta_type}_metadata" filter returns false.
Reported by: | jsmoriss | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.2.2 |
Component: | Options, Meta APIs | Keywords: | |
Focuses: | Cc: |
Description
metadata_exists() applies the "get_{$meta_type}_metadata" filter. If the $single metadata value is false, 0, an empty string, or an empty array (see https://www.php.net/manual/en/language.types.boolean.php), then metadata_exists() will return false instead of true (ie. the metadata exists).
function metadata_exists( $meta_type, $object_id, $meta_key ) { . . . $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true, $meta_type ); if ( null !== $check ) { return (bool) $check; }
If any value is returned, then the metadata exists, so the code should be:
function metadata_exists( $meta_type, $object_id, $meta_key ) { . . . $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true, $meta_type ); if ( null !== $check ) { return true; }
js.
Note: See
TracTickets for help on using
tickets.