php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71202 Autoload function registered by another not activated immediately
Submitted: 2015-12-23 13:22 UTC Modified: -
From: web001 at zeroj dot net Assigned:
Status: Closed Package: SPL related
PHP Version: 7.0.1 OS: OS X 10.10.1
Private report: No CVE-ID: None
 [2015-12-23 13:22 UTC] web001 at zeroj dot net
Description:
------------
See test script. An autoload function was added to autoload queue in another autoload function. But the "child" autoload function was not called after other functions.
It works on 5.5 and 5.6.

Test script:
---------------
<?php
spl_autoload_register(function($name){
    if($name == 'C') {
        spl_autoload_register(function($name){
            if($name == 'C') {
                class C {
                    function __construct(){
                        echo "I'm C.\n";
                    }
                }
            }
        });
    }
});

$c = new C();


Expected result:
----------------
I'm C.

Actual result:
--------------
PHP Fatal error:  Uncaught Error: Class 'C' not found

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-23 15:48 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e21cb2daeabe459db996407df2113bb47a320937
Log: Fixed bug #71202 (Autoload function registered by another not activated immediately)
 [2015-12-23 15:48 UTC] [email protected]
-Status: Open +Status: Closed
 [2016-07-20 11:34 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e21cb2daeabe459db996407df2113bb47a320937
Log: Fixed bug #71202 (Autoload function registered by another not activated immediately)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 09 01:01:26 2025 UTC