From:             
Operating system: 
PHP version:      5.3.3
Package:          *General Issues
Bug Type:         Bug
Bug description:require fails in error handler when E_STRICT is emitted from 
namespace class

Description:
------------
When an E_STRICT error is emitted from a class within a namespace and this
is 

caught in a custom error handler, then require_once() fails.



To demonstrate this bug, I created a minimal test below. It consists of 3
files. 

Place them in a directory and execute test.php from the command line.

Test script:
---------------
************* file test.php ******************

<?php

error_reporting(E_ALL | E_STRICT);



// Custom error handler.

function handle_error($code, $message, $file, $line, $context) {

        $code = $code & error_reporting();

        if ($code == 0) { // skip @ suppressed errors.

                return;

        }

        $errors = array(

                E_ERROR                         => 'E_ERROR',

                E_WARNING                       => 'E_WARNING',

                E_PARSE                         => 'E_PARSE',

                E_NOTICE                        => 'E_NOTICE',

                E_CORE_ERROR            => 'E_CORE_ERROR',

                E_CORE_WARNING          => 'E_CORE_WARNING',

                E_COMPILE_ERROR         => 'E_COMPILE_ERROR',

                E_COMPILE_WARNING       => 'E_COMPILE_WARNING',

                E_USER_ERROR            => 'E_USER_ERROR',

                E_USER_WARNING          => 'E_USER_WARNING',

                E_USER_NOTICE           => 'E_USER_NOTICE',

                E_STRICT                        => 'E_STRICT',

                E_DEPRECATED            => 'E_DEPRECATED',

        );

        if (array_key_exists($code, $errors)) {

                $errname = $errors[$code];

        }

        else {

                $errname = $code;

        }

        $error = "Error handler caught $errname with message \"" . $message . '"
at ' . $file . ' line ' . $line . ".\n";

        error_log($error);

        require_once('bla.php');

        bla($error);

        return;

}

set_error_handler('handle_error');



// This fails because bla.php can't be required in error handler:

require_once('Abstract.php');







*************** Abstract.php **************

<?php

namespace MyNamespace {

        abstract class AbstractFoo {

                abstract public static function foo(); // PHP 5.3 issues an 
E_STRICT here
about abstract + static, even though it now supports static inheritance.

        }

}









*************** bla.php ******************

<?php

function bla() {

        print "You should see this.\n";

}

Expected result:
----------------
Error handler caught E_STRICT with message "Static function 

MyNamespace\AbstractFoo::foo() should not be abstract" at 

/home/cmanley/0/Abstract.php line 4.



You should see this.

Actual result:
--------------
Error handler caught E_STRICT with message "Static function 

MyNamespace\AbstractFoo::foo() should not be abstract" at 

/home/cmanley/0/Abstract.php line 4.



PHP Fatal error:  Call to undefined function bla() in
/home/cmanley/0/Abstract.php 

on line 4

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

Reply via email to