From:             tyrael
Operating system: irrelevant
PHP version:      5.4.17
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:compile time errors won't trigger auto loading

Description:
------------
I originally reported this under #65317 but after looking into it a bit
more 
(thanks laruence) it turned out that the original report was a little bit 
misleading:
the autoloader isn't prevented because we are already in an autoload call,
but 
because the engine won't call the autoloaders for errors from compilation 
time(zend_lookup_class_ex):

    /* The compiler is not-reentrant. Make sure we __autoload() only during
run-
time
     * (doesn't impact fuctionality of __autoload()
    */
    if (!use_autoload || zend_is_compiling(TSRMLS_C)) {
        if (!key) {
            free_alloca(lc_free, use_heap);
        }
        return FAILURE;
    }

I would be curious how come that it is safe to call the autoloader (which
in 
turn can do anything, include other files or call the autoloaders
manually), but 
not safe to call the autoloader in this case.

Test script:
---------------
<?php
set_error_handler(function($errno, $errstr, $errfile, $errline){
        echo $errstr."\n";
        new MyClass;
});

spl_autoload_register(function($class){
    echo $class."\n";
    return eval("class $class{}");
});

eval('
        class MyConcrete extends MyAbstract {
                public static function createInstance() {}
        }
        abstract class MyAbstract {
                public abstract static function createInstance();
        }
');

Expected result:
----------------
call the autoloader

Actual result:
--------------
autoloader not called, fatal error is triggered by the missing class

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

Reply via email to