From:             woody dot gilk at gmail dot com
Operating system: Mac OSX 10.5
PHP version:      5.2.10
PHP Bug Type:     Scripting Engine problem
Bug description:  Invalid error reporting with __toString() method

Description:
------------
When using a custom error handler, it is possible to make PHP trigger an 
E_FATAL by concatenating an object with a __toString() method together 
with a variable that is not set.

Tested in 5.2.9 and 5.2.10.

Reproduce code:
---------------
<?php

class test {

        public static function error_handler($code, $error, $file = NULL, $line 
=
NULL)
        {
                // This error is not suppressed by current error reporting 
settings
                throw new ErrorException($error, $code, 0, $file, $line);
        }

        public static function run()
        {
                $object = new self;

                echo $object.$foo;
        }

        public function __toString()
        {
                return __CLASS__;
        }

}

error_reporting(E_ALL);

set_error_handler(array('test', 'error_handler'));

test::run();

Expected result:
----------------
PHP Fatal error:  Uncaught exception 'ErrorException' with message 
'Undefined variable: foo' in php_bug.php:15
Stack trace:
#0 php_bug.php(15): test::error_handler()
#1 php_bug.php(29): test::run()
#2 {main}
  thrown in php_bug.php on line 15

Actual result:
--------------
PHP Fatal error:  Method test::__toString() must not throw an exception 
in

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

Reply via email to