I client of mine recently upgraded a very basic WordPress install to version 5.6.1. While the update seemed to go well, right at the very end the site died with an error that read something like this; identifying details altered for privacy:
[Sat Feb 06 12:12:11.123456 2021] [fcgid:warn] [pid 128] [client 220.127.116.11:12345] mod_fcgid: stderr: PHP Fatal error: Uncaught Error: Class 'WP_Site_Health' not found in /var/www/html/wp-includes/rest-api.php:321
I have fairly deep experience debugging WordPress and related PHP sites, but this was baffling. According to them they disabled all of the plug-ins and themes and even downloaded a clean archive of WordPress 5.6.1 and did the basic manual upgrade process of retaining the
.htaccess and related user specific uploads in the
wp-content directory and the error still shows up.
I’ve read advice like what was posted here on the WordPress forums that basically state one should restore from a backup and try again, but find that advice to be a classic “Hail Mary” play; sometimes it works and other times you are just left in the same exact position as before but with new file modification dates.
So given that the class
WP_Site_Health and the file
wp-includes/rest-api.php are both items that exist in core WordPress, what can be done to quickly patch the system to get it working again?
P.S.: And to truly confirm the files were fine, I did the following:
- Created a Tar/Gzip archive of the whole WordPress install — including all
wp-contentitems — and downloaded it to my desktop.
- Then I decompressed the archive, went into that directory and ran
git initinside of it to create a Git repo.
- I left the site as-is as the
masterbranch and then created a new branch called
- In that test branch, I manually downloaded a 100% WordPress 5.6.1 install from WordPress directly, manually copied the clean files into the new branch and committed them.
- Then I ran local
git diff master..testto see what files were changed between the source
masterbranch and the
testbranch. The diff said the files from the server versus clean WordPress 5.6.1 files were 100% the same; what was on the server is 100% the same as a clean WordPress install.