0

I recently re-did my local dev setup and have been seeing these types of fatal error warnings:

There has been a critical error on this website. Please check your site admin email inbox for instructions.

Learn more about troubleshooting WordPress.

When I disable the "fatal error catcher" of WP like below to get the actual debug trace of the error I am not seeing anything logged or rendered. I am seeing other error_log(..) entries appearing in /wp-content/debug.log.

wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );

From phpinfo() it shows display_errors as On (so not the same issue as in this questions).

How can I get to see the debug trace of those fatal errors?

5
  • 1
    have you used a process of elimination to determine which theme/plugin/file it is that's causing it? Have you checked the server level error log rather than the WP specific one at wp-content/debug.log? Your host can point you towards it if you're not sure where that is
    – Tom J Nowell
    Commented Nov 9, 2022 at 13:12
  • @TomJNowell Jep, it's a localhost setup for dev; no logs in my server/host specific log. And I do get e.g. array index offset warnings and other errors into debug.log — just the Fatal ones show up nowhere.
    – kontur
    Commented Nov 9, 2022 at 13:29
  • be sure you're checking the PHP log and not the Apache/Nginx log, and that php.ini is configured to log to an error log. Also errors don't just randomly occur like this, they always have a cause and pattern, so narrowing it down further will be important
    – Tom J Nowell
    Commented Nov 9, 2022 at 13:59
  • @TomJNowell Thanks, I'm not trying to debug one specific issue, but generally the fact that I don't get traces for these. Often it's using a WP object as Array or other simple mistakes, but without the trace it can be quite a challenge to narrow them down. For $ php -i I get php -i | grep "log"` error_log => no value => no value and log_errors => On => On, viewing phpinfo() output in the project I have error_log pointing to the local /wp-content/debug.log file of that project.
    – kontur
    Commented Nov 10, 2022 at 9:05
  • then it seems you don't have a PHP error log, and are relying on the WP debug.log, which is suboptimal. It means anything that fails before the WP error handler is added is not logged or caught because content/debug.log has not been set yet. You also have the problem that if your error reporting level is weird it may not log certain types of error at all. Likewise if you use @ a lot, @ does not fix errors, it silences them, the error still happens. I don't think this is necessarily WP specific and you're shooting yourself in the foot by looking only in WP circles. It's generic PHP
    – Tom J Nowell
    Commented Nov 10, 2022 at 12:00

1 Answer 1

0

Something, I do not know what, is resetting my global error_reporting(E_ALL) level to a higher level, thus hiding the errors. Explicitly adding the lower error_reporting in files in question helps show the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.