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

Catchable fatal error when tracing __PHP_Incomplete_Class #56

Closed bobbingwide closed 7 years ago

bobbingwide commented 7 years ago

Actual output

When bw_backtrace() is passed an incomplete object, which could have been created during unserialize(), then it produces the following message: Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in oik-bwtrace\includes\bwtrace.php on line 964

Expected output

oik-bwtrace should not be producing this message during bw_backtrace().

Explanation

The logic to determine what to print for function parameters doesn't detect the __PHP_Incomplete_Class and there is no try / catch logic.

Proposed solution

The simplest solution is to check is_scalar() before appending the value. In the final else situation just print unsupported. This is only a back trace after all. If you really want to see the values you should bw_trace2() the parameter in a separate call. Better test that as well!

Additional notes

In certain circumstances this message will cause the invoking routine to terminate unexpectedly. This problem was discovered when analysing https://deliciousbrains/wp-migrate-db/issues/70

bobbingwide commented 7 years ago

Note: In PHP 7.1 the messsage is Recoverable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string ...