0
votes

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
Are you by any chance using betheme? or you have revslider? or jscomposer?Masivuye Cokile
Yes to revslider and yes to jscomposer, jscomposer can show and render previous pages but is unable to edit them. Revslider seems to be working properly.K. Weber
The problem is jscomposer.... I will check now for you which line I experienced this a lot.... try and set error reporting of your server onMasivuye Cokile
Uncaught Error: [] operator not supported for strings in ../wp-content/plugins/revslider/includes/framework/base-admin.class.php:71 can you check your revslider for line 71Masivuye Cokile
But if I disable both plugins I have the same error, so my problem is different than yours. I need a way to find log for the real error. Thank you.K. Weber

2 Answers

0
votes

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.

0
votes

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.