Make WordPress Core

Opened 6 months ago

Last modified 5 months ago

#60314 new defect (bug)

Revisions: PHP Warning: Undefined array key 0 in .../wp-includes/meta.php on line 642

Reported by: picocodes's profile picocodes Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.4.2
Component: Autosave Keywords: has-patch
Focuses: Cc:


  • 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:
    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.

5 months ago

  • Keywords has-patch added

I've removed the single parameter so that it is handled in a single place:-

Currently, it is handled in two places, leading to a PHP notice when the meta value is an associative array.

Trac ticket:

Note: See TracTickets for help on using tickets.