So, WordPress 5.2 and later have the "Fatal Error Recovery Mode" feature. It sends you an email ("Your Site is Experiencing a Technical Issue") whenever an exception occurs. This is implemented as an exceptions handler, same idea as our Admin Tools for Joomla feature.
The thing is, if we want to implement the same feature in WordPress we have two routes.
The first route is by making use of a Must-Use plugin (see wp-content/mu-plugins
) to add a filter for wp_php_error_message
.
The other is to have the user jump through some rather grueling configuration hoops which involve editing the wp-config.php to add / change some constants, and place some drop-ins into the wp-content
directory.
Clearly, the first method is much better, and I have a proof-of-concept I am using for local debugging.
This is where things get a bit hairy. Joomla will use a separate exceptions handler and a specific, custom exception type if the problem has to do with the fact that the database is not accessible. Not WordPress. A database connectivity issue will be handled by the Fatal Error Recovery Mode which will run the wp_php_error_message
filter. And yes, our code would also run because mu-plugins are loaded based on their presence in the filesystem, not whether they're activated in the database (as opposed to Joomla only loading plugins if they are marked as enabled in the database). This means we'd try to ask WordPress which email address to send the email message to, which requires database connectivity, thus raising a different exception which now points to a problem in Admin Tools instead of WordPress itself. The same problem occurs if the exception is thrown because WordPress cannot load its mailer, or if the mailer loaded experiences an issue (think about a timeout connecting to an SMTP server).
I am still looking for a reliable way to avoid these problems. In the meantime, you can read about the core WordPress feature at https://make.wordpress.org/core/2019/04/16/fatal-error-recovery-mode-in-5-2/.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!