• For a few weeks now, in the classic post editor, if I click a link for a revision, I receive the “There has been a critical error on this website. Please check your site admin email inbox for instructions.” error message.
    Up on checking the apache logs, this is what’s causing the problem:

    PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /var/www/html/wp-includes/formatting.php:5365\nStack trace:\n#0 /var/www/html/wp-includes/formatting.php(5365): trim()\n#1 /var/www/html/wp-includes/pluggable.php(2919): normalize_whitespace()\n#2 /var/www/html/wp-admin/includes/revision.php(118): wp_text_diff()\n#3 /var/www/html/wp-admin/includes/revision.php(337): wp_get_revision_ui_diff()\n#4 /var/www/html/wp-admin/revision.php(137): wp_prepare_revisions_for_js()\n#5 {main}\n thrown in /var/www/html/wp-includes/formatting.php on line 5365, referer: (my-post-link)

    How do I fix this problem?

    PS: I’m in the latest version of WordPress. I switched the theme, and I’m getting the same error.

    • This topic was modified 2 years, 1 month ago by wpmhweb.
    • This topic was modified 2 years, 1 month ago by wpmhweb.
    • This topic was modified 2 years, 1 month ago by wpmhweb.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Which PHP version are you using? I guess 8.1. Try to reset to 8.0 or 7.4.

    I am on php8.0 and have the exact same error. is there any fix ?

    We have the same error and this page was the first result in Google, so I thought I’ll share my findings, maybe it helps someone. (Didn’t help me so far, but who knows.)
    A bare WordPress 6.1 or newer doesn’t have the problem with PHP 7.4, 8.0, 8.1 or 8.2. That’s because they only check the differences in title, content and excerpt which are all strings. Some plugins or themes might hook into _wp_post_revision_fields and add fields that are arrays. The “type safety” in the function wp_get_revision_ui_diff doesn’t account for this and that’s when everything breaks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to fix critical error trying to check post revision?’ is closed to new replies.