From:             
Operating system: Irrelevant
PHP version:      5.3.5
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:The notorious "Call to a member function .. on a non-object" 
fatal error

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 bug report at http://bugs.php.net/bug.php?id=54195&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=54195&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=54195&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=54195&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=54195&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54195&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=54195&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=54195&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=54195&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=54195&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=54195&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=54195&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=54195&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=54195&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=54195&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54195&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54195&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=54195&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=54195&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=54195&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=54195&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=54195&r=mysqlcfg

Reply via email to