Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to show errors when you get a white screen in EE. Turning up the debugging will reveal PHP errors.

Overview

Below are two techniques to help debug the WSOD (white screen of death), usually a 500 server error, in an ExpressionEngine site. The Basic-Debugging option will be suitable in most cases and is specific to ExpressionEngine. The Advanced-Debugging is generic and applicable to any PHP based software. If the basic debugging does not work, try the advanced.

If you get a WSOD you will need to first get your site to reveal an error before reporting it to EllisLab or the add-on developer. Simply reporting "I get a white screen" does not give the developer enough information to assist you. An error message on the other hand will point the developer to the source of the issue.

In your config.php file, find $config['debug'] and set it to 2:
$config['debug'] = 2;
In your index.php and admin.php files, find $debug and set it to 1:
$debug = 1;
<?php
// Taken from http://stackoverflow.com/questions/1475297/phps-white-screen-of-death/18208549#18208549
// Add this to the top of your index.php file.
ini_set('display_errors', 'On');
ini_set('html_errors', 0);
error_reporting(-1);
function ShutdownHandler() {
if(@is_array($error = @error_get_last())) {
return(@call_user_func_array('ErrorHandler', $error));
};
return(TRUE);
};
register_shutdown_function('ShutdownHandler');
function ErrorHandler($type, $message, $file, $line) {
$_ERRORS = Array(
0x0001 => 'E_ERROR',
0x0002 => 'E_WARNING',
0x0004 => 'E_PARSE',
0x0008 => 'E_NOTICE',
0x0010 => 'E_CORE_ERROR',
0x0020 => 'E_CORE_WARNING',
0x0040 => 'E_COMPILE_ERROR',
0x0080 => 'E_COMPILE_WARNING',
0x0100 => 'E_USER_ERROR',
0x0200 => 'E_USER_WARNING',
0x0400 => 'E_USER_NOTICE',
0x0800 => 'E_STRICT',
0x1000 => 'E_RECOVERABLE_ERROR',
0x2000 => 'E_DEPRECATED',
0x4000 => 'E_USER_DEPRECATED'
);
if(!@is_string($name = @array_search($type, @array_flip($_ERRORS)))) {
$name = 'E_UNKNOWN';
};
return(print(@sprintf("%s Error in file %s at line %d: %s\n", $name, @basename($file), $line, $message)));
};
$old_error_handler = set_error_handler("ErrorHandler");
?>
@narration-sd

This comment has been minimized.

Copy link

@narration-sd narration-sd commented May 17, 2013

And might want to say, after the problem is resolved, return the debug values to their original states, to avoid security hazard and other embarrassments.

In your config.php file, find $config['debug'] and set it to 1:

$config['debug'] = 1;

In your index.php and admin.php files, find $debug and set it to 0:

$debug = 0;

@litzinger

This comment has been minimized.

Copy link
Owner Author

@litzinger litzinger commented Jul 30, 2013

its also worth noting that near the bottom of index.php and admin.php is the following:

if (DEBUG == 1)
{
    error_reporting(E_ALL);
    @ini_set('display_errors', 1);
}
else
{
    error_reporting(0); 
}

Change it to this and it sometimes helps reveal errors:

// if (DEBUG == 1)
// {
    error_reporting(E_ALL);
    @ini_set('display_errors', 1);
// }
// else
// {
//  error_reporting(0); 
// }
@carltondickson

This comment has been minimized.

Copy link

@carltondickson carltondickson commented Sep 1, 2017

Expression engine was supressing a mysql error which was really annoy...hadn't installed the PHP mysql extension and also had the wrong host address.

	function db_connect()
	{
		if ($this->port != '')
		{
			$this->hostname .= ':'.$this->port;
		}

		return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment