bobbingwide / oik-bwtrace

debug trace for WordPress
https://www.oik-plugins.com/oik-plugins/oik-bwtrace-debug-trace-for-wordpress/
GNU General Public License v2.0
6 stars 1 forks source link

WSOD when Trace Error, Warning and Notice messages checked in WPENGINE #1

Closed bobbingwide closed 9 years ago

bobbingwide commented 9 years ago

While testing oik-bwtrace v2.0.3 on my WP Engine hosting account I encountered a White Screen Of Death as soon as I selected the Trace Error, Warning and Notice messages checkbox.

This is due to trace output being written using print_r() when output buffering is active.

bobbingwide commented 9 years ago

Problem explanation

WP Engine delivers a number of mu-plugins which do extra work on wp-admin. The code is written using the PHP Error Control Operator @ to prevent notices from being displayed when a variable is not set.

While this prevents Notices from being displayed by the standard error handler these Notices still get passed to user written error handlers.

There is also a problem using print_r() when PHP output buffering is active.

I wrote about this here http://bobbingwide.com/phphants/2013/11/03/fatal-error-print_r-cannot-use-output-buffering-in-output-buffering-display-handlers/

URL edited 2019/11/22

The sequence of events leading to the WSOD is

bobbingwide commented 9 years ago

Problem resolution - oik-bwtrace

In Nov 2013 I wrote a simple plugin that delivered a function called obsafe_print_r() that oik-bwtrace would use if available. In oik-bwtrace v2.0.4 I have incorporated a reworked version of the function to use when trace detects that output buffering is active.

Problem resolution - WP Engine

I also suggest that WP Engine rewrite their code to use isset( $_GET['page'] ) before attempting to test the value. This will reduce the number of Notices that my trace routine detects.

bobbingwide commented 9 years ago

See documentation for print_r ( http://us.php.net/manual/en/function.print-r.php ) for the Note: that explains the problem

Note: When the return parameter is used, this function uses internal output buffering so it cannot be used inside an ob_start() callback function.