Opened 4 months ago
Last modified 5 weeks ago
#58992 new defect (bug)
get_metadata_raw() "get_{$meta_type}_metadata" filter can return incorrect value for $single = true
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.2.2 |
Component: | Options, Meta APIs | Keywords: | |
Focuses: | Cc: |
Description
The "get_{$meta_type}_metadata" filter includes the $single argument for the filter to return a single element or the complete metadata array. If the single element happens to be an array, and that array is returned because $single = true, then the following code breaks the returned value (it returns the first element instead of the array). If the array is an associative array, then it also breaks the returned value as $check[0]
is not a valid element.
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type ); if ( null !== $check ) { if ( $single && is_array( $check ) ) { return $check[0]; } else { return $check; } }
Since $single is provided to the filter, the code should respect the returned value:
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type ); if ( null !== $check ) { return $check; }
js.
Note: See
TracTickets for help on using
tickets.