Most WSoDs are caused by a PHP error that haults processing combined with configuration that prevents the error from being shows in the browser.
The fastest way to debug white screen errors is to turn on logging and startup errors. The instructions below assume you are running under Apache with an Override setting that will allow php_flag and php_value directions in your .htaccess file.
Of course, before changing any files make sure you have a backup of the database and files!
Create a directory in your home directory named log and make it writeable:
$ cd ~
$ mkdir log
$ chmod -R 777 log
Create an .htaccess file in the root of your project with these lines in it:
php_flag display_errors 1
php_flag display_startup_errors 1
php_value error_reporting 30719
php_value error_log /home/USER/log/PROJECT.log
php_flag log_errors 1
I'd recommend putting the following line at the top of your front controllers (your root level /system/index.php, /index.php and /admin.php) so you can see what requests cause what log output:
error_log($_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['PHP_SELF'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''));
While making the request that crashes EE, watch the log file with:
$ tail -f /home/USER/log/PROJECT.log
The htaccess file does a few things:
- Sets error reporting to the current
E_ALL value (you cannot use constants in .htaccess).
- You should see any syntax errors - that's what
- If the code turns off
display_errors anywhere (pretty common when you are using a lot of third party code) you should still see the errors in the log.
If this doesn't work, look in your codebase for the following things. ack works best for this - it's like grep on steroids - but you can instead use your text editor's Find in Files functionality to search through a local copy if you have FTP-only access.
Stuff to check for (each of these is a call that may or may not have arguments, just search for each word listed and take the recommended action):
@require - any of these will ignore syntax errors in the included files. Change these to not have the @ sign so that errors inside them will show up. I believe there is still at least one reference to @require in the Extensions.php file, although this might have been removed finally.
@eval - less likely than the above but would also ignore syntax errors. This shouldn't be used by core EE but could be used by add-ons. Change to not have the @ sign.
die - obvious probably, but make sure there is an echo before any of these so that you can see which one caused the output to end (resulting in a White screen).
log_errors - see if someone is turning off error logging for some reason.
error_reporting - comment out all of these in third-party add-ons as well as the core. Any of these will disable error reporting to not match the settings provided above.
ini_set('display_errors', '0') or
ini_set('display_errors', 0) or
ini_set('display_errors', false)- comment out all of these as well
If this still doesn't work, you can use a PHP debugger to trace through the code (such as XDebug and one of the many debugging GUI front-ends available such as PhpStorm), or add
error_log(print_r($something, true)) calls to write things to the log. This is a lot better than print or echo because it can't be erased or output buffered and gets written instantly to the log file.
Hope this helps.