Edit report at http://bugs.php.net/bug.php?id=54195&edit=1
ID: 54195 Comment by: tyra3l at gmail dot com Reported by: landeholm at gmail dot com Summary: The notorious "Call to a member function .. on a non-object" fatal error Status: Open Type: Bug Package: Scripting Engine problem Operating System: Irrelevant PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: I've mentioned this on the list, but to be archived: AFAIK register_shutdown_function should be called on every errors, even on the fatal ones, and it does. at least for me, both on windows, and linux: tyrael@devel-tyrael:~/c$ php -f fatal.php PHP Fatal error: Call to a member function bar() on a non-object in /home/tyrael/c/fatal.php on line 9 PHP Stack trace: PHP 1. {main}() /home/tyrael/c/fatal.php:0 Houston we have a problem: Array ( [type] => 1 [message] => Call to a member function bar() on a non-object [file] => /home/tyrael/c/fatal.php [line] => 9 ) as you can see from the output of the example code provided by Hannes Landeholm, it does called on the fatal error. if it doesn't work for Hannes, then I think that there are some difference in our setup/configuration. Tyrael Previous Comments: ------------------------------------------------------------------------ [2011-03-08 15:40:17] landeholm at gmail dot com Description: ------------ I had this problem a million times. It's very easy to accidentally invoke "Fatal Error: Call to a member function .. on a non-object". The problem is that this triggers an error so fatal that it can't even be caught by the shutdown function. This recently gave me a huge headache in a production system where an obscure bug where a variable contain null which was called on invoked a silent crash. It's a headache because I run everything in a framework with great wrappers for error handling/detection that are suppose to send me an email when obscure bugs get tripped. This obviously doesn't work when the PHP commits seppuku and explodes. I don't see any reason for this error to be that fatal. Sure, keep the error fatal but at least allow the shutdown function to catch it. Test script: --------------- \register_shutdown_function(function(){ $e = \error_get_last(); if (!\is_null($e)) die('Houston we have a problem: ' . \print_r($e, true)); }); $hello = null; $hello->bar(); Expected result: ---------------- Houston we have a problem: Array ( ... Actual result: -------------- Fatal error: Call to a member function bar() on a non-object in ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54195&edit=1