Support

Admin Tools for WordPress

#42102 Email on PHP error?

Posted in ‘Admin Tools for WordPress’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

WordPress version
6.8.1
PHP version
8.3.22
Admin Tools version
1.7.1

Latest post by nicholas on Wednesday, 09 July 2025 12:33 CDT

UglyEoin

Please look at the bottom of this page (under Support Policy Summary) for our support policy summary, containing important information regarding our working hours and our support policy. Thank you!

 

In Admin Tools Joomla there's an option to email on a PHP error,which means I troubleshoot errors as they happen, not when a client phones me up screaming.

 

I don't see this option in WordPress.  Is that for any reason, i.e. is there a better way or a way that already exists in WP?

nicholas
Akeeba Staff
Manager

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!

UglyEoin

I see, I guess if WP notifies us that's not the end of the world.  It's not a great error message, but it's better than nothing.  

nicholas
Akeeba Staff
Manager

I have some ideas about how to make this happen. Stay tuned :)

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!