skip to Main Content

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


  1. Chosen as BEST ANSWER

    So, I found the script where Wordpress handles fatal errors, and where it masks these errors under the generic message:

    The site is experiencing technical difficulties. Please check your email for instructions.

    The script /wp-includes/class-wp-fatal-error-handler.php handles these errors, under a try..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 the try..catchand 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.

    public function handle() {
            if ( defined( 'WP_SANDBOX_SCRAPING' ) && WP_SANDBOX_SCRAPING ) {
                return;
            }
            // comment try..catch
            // try {
                // Bail if no error found.
                $error = $this->detect_error();
                if ( ! $error ) {
                    return;
                }
    
    //log error message
    error_log($error["message"]);
    return;
    
                if ( ! isset( $GLOBALS['wp_locale'] ) && function_exists( 'load_default_textdomain' ) ) {
                    load_default_textdomain();
                }
    
                if ( ! is_multisite() && wp_recovery_mode()->is_initialized() ) {
                    wp_recovery_mode()->handle_error( $error );
                }
    
                // Display the PHP error template if headers not sent.
                if ( is_admin() || ! headers_sent() ) {
                    $this->display_error_template( $error );
                }
            // } catch ( Exception $e ) {
                // Catch exceptions and remain silent.
            // }
        }
    

    The function error_log will log error to wp-content/debug.log in the case that this line exists in your wp-config.php file:

    define( 'WP_DEBUG_LOG', true );
    

    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.


  2. Please follow the below steps:

    1. 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 );

    2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search