Opened 3 years ago
Last modified 3 years ago
#58993 new defect (bug)
metadata_exists() returns incorrect value when "get_{$meta_type}_metadata" filter returns false.
| Reported by: | jsmoriss | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Options, Meta APIs | Version: | 6.2.2 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)