Opened 9 months ago
Last modified 8 months ago
#60314 new defect (bug)
Revisions: PHP Warning: Undefined array key 0 in .../wp-includes/meta.php on line 642
Reported by: | picocodes | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.4.2 |
Component: | Autosave | Keywords: | has-patch |
Focuses: | Cc: |
Description
- Call register_post_meta() with single = true, type = object and revisions_enabled = true.
- Save your meta value as an associative array.
- Next, call get_post_meta on a post that has a revision.
- The following filter will fire:
<?PHP add_filter( 'get_post_metadata', '_wp_preview_meta_filter', 10, 4 );
- Then return a single associative array.
- WordPress will treat this as multiple meta values and then try to return the first index hence leading to the above notice.
If this is the intended behaviour then at least add a notice to the register_post_meta function.
Change History (1)
This ticket was mentioned in PR #6115 on WordPress/wordpress-develop by @picocodes.
8 months ago
#1
- Keywords has-patch added
Note: See
TracTickets for help on using
tickets.
I've removed the single parameter so that it is handled in a single place:- https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/meta.php#L637
Currently, it is handled in two places, leading to a PHP notice when the meta value is an associative array.
Trac ticket: https://core.trac.wordpress.org/ticket/60314