php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65322 compile time errors won't trigger auto loading
Submitted: 2013-07-24 08:55 UTC Modified: 2013-08-29 15:20 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: tyrael@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.4.17 OS: irrelevant
Private report: No CVE-ID:
 [2013-07-24 08:55 UTC] tyrael@php.net
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-29 15:20 UTC] tyrael@php.net
-Status: Open +Status: Duplicate
 [2013-08-29 15:20 UTC] tyrael@php.net
duplicate of https://bugs.php.net/bug.php?id=54054 which is in turn duplicate of 
https://bugs.php.net/bug.php?id=42098 from 2007.
 [2013-09-29 16:04 UTC] nikic@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f0c926564c5f7de9462d9ca7bd75014b14a63f56
Log: Fix bug #65322: compile time errors won't trigger auto loading
 [2013-09-29 16:04 UTC] nikic@php.net
-Status: Duplicate +Status: Closed
 [2013-10-20 17:06 UTC] nicolas dot grekas+php at gmail dot com
Thanks for the fix, waited since 2007 :)

Did this also fix https://bugs.php.net/60724 ?
I'm asking because this one is also related to compile time behavior.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 12:01:52 2014 UTC