[wp-trac] [WordPress Trac] #64314: Fatal error when enabling revisions for post meta of type array/object

WordPress Trac noreply at wordpress.org
Wed Nov 26 23:17:33 UTC 2025


#64314: Fatal error when enabling revisions for post meta of type array/object
-------------------------------+-----------------------------
 Reporter:  LAPSrj             |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  6.8.3
 Severity:  critical           |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 Since WordPress 6.4 it is now possible to enable revisions for post meta.
 However when verifying if there are changes in the meta fields the
 function expects only strings, breaking if the meta format is array or
 object.

 How to reproduce the bug:
 - Register a post meta of type array/object
 - Set a value for it in a post
 - Try to save the post

 The API request to save the post will fail, returning a 500 error. The PHP
 log will list say:

   PHP Fatal error:  Uncaught TypeError: trim(): Argument #1 ($string) must
 be of type string, array given

 The cause of the error is the function `wp_save_post_revision`, at `wp-
 includes/revision.php`. At line 190 it uses `normalize_whitespace(
 $post->field )`, which only works with strings, however `$post->field`
 will be an array if the meta is an array  and that will cause the fatal
 error.

 Since this is a supported feature since WordPress 6.4 and is causing fatal
 errors, I'm setting the severity to critical. Even though the issue is
 with meta fields, I'm setting the component as "Posts, Post Types" because
 the issue is at the part that handles saving the revisions and the same
 code is used both to fetch post attributes and post meta.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64314>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list