|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48493 spl_autoload_unregister() removes all autoloaded methods when prepending
Submitted: 2009-06-08 08:20 UTC Modified: 2009-06-09 01:58 UTC
From: craig dot marvelley at boxuk dot com Assigned:
Status: Closed Package: SPL related
PHP Version: 5.3.0RC2 OS: Windows XP
Private report: No CVE-ID: None
 [2009-06-08 08:20 UTC] craig dot marvelley at boxuk dot com
The spl_autoload_register function was recently modified (I don't think 
it's documented, though) to allow the pre-pending of functions to the 
stack (see bug #42823).

I'm using pre-pending and am later trying to remove a registered 
function from the end of the stack. This removes ALL methods, not just 
the method I'd intended.

Reproduce code:
function autoload1() {}

function autoload2() {}


// register autoload1 at the bottom of the stack
spl_autoload_register('autoload1', true, true);

// Output: Array ( [0] => autoload1 [1] => autoload2 )

// unregister autoload2 - autoload1 _should_ be left behind

Expected result:
When running spl_autoload_functions(), I'd expect a single entry to be 
left: array([0] => 'autoload1');

Actual result:
The array is empty: array();


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-09 01:58 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 07:05:46 2022 UTC