Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#58249 new enhancement

Improve "get_metadata_raw()" by Delegating "$single" Handling to Filter

Reported by: donglijun's profile donglijun Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.3
Component: Options, Meta APIs Keywords: has-patch
Focuses: Cc:

Description

In the current implementation of the get_metadata_raw() function, after obtaining the result from the get_{$meta_type}_metadata filter, the code checks $single and is_array() and may return the first element of the result instead of the entire result. This can cause unnecessary ambiguity when the retrieved meta value from filter is an array which is serialized and stored in database.

It appears that get_metadata_raw() assumes the get_{$meta_type}_metadata filter will unserialize the meta value, but not handle the $single parameter.

To improve clarity and efficiency, I recommend delegating the responsibility of handling the $single logic to the get_{$meta_type}_metadata filter. This change will streamline the get_metadata_raw() function and provide more consistent handling of meta values.

Attachments (1)

58249.diff (595 bytes) - added by donglijun 5 months ago.

Download all attachments as: .zip

Change History (2)

@donglijun
5 months ago

#1 @donglijun
5 months ago

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.