I have upgraded a not so old version of a WordPress site and also upgraded the server from php 5.6 to php 7.2 (all this in a local and controlled environment).
The site has a few plugins and a custom theme. Plugins where disabled and re-enabled one by one to control errors.
After the upgrade of all plugins that allowed an upgrade I’ve been tracking errors and solving them until this point where I am, where:
When entering theme options and another plugin configuration I get the error message:
The site is experiencing technical difficulties. Please check your email for instructions.
I don’t find any error trace in apache/php error log and in WordPress debug log. All PHP configuration is set up to show all errors and my wp-config.php
file has these lines to force debug and log:
define('WP_DEBUG', true );
define('WP_DEBUG_LOG', true );
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Where can I get more specific information about these errors? I know which plugins/theme cause them, but I need to debug and locate the lines where they happen.
Thank you.
2
Answers
So, I found the script where Wordpress handles fatal errors, and where it masks these errors under the generic message:
The script
/wp-includes/class-wp-fatal-error-handler.php
handles these errors, under atry..catch
block, which makes it impossible to the error message to show up.So, a temporal solution, only for debugging, is to modify the method
handle()
to disable thetry..catch
and log the error message, like shown here:disclaimer: this modification must be undone once the site is put into production, it's only for debugging purposes.
The function
error_log
will log error towp-content/debug.log
in the case that this line exists in yourwp-config.php
file:Or to Apache/php error log otherwise.
Sure there are other ways and other configurations to debug these errors but this is an easy one.
Please follow the below steps:
Paste these below code in wp-config.php
define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, true );
@ini_set( ‘display_errors’, 1 );
define( ‘SCRIPT_DEBUG’, true );
create a file named debug.log in the wp-content directory.
3.Run your WordPress website like before and open debug.log file in any text editor.
You will find all the everything (erros) here.