php.net |  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:
 [2009-06-08 08:20 UTC] craig dot marvelley at boxuk dot com
Description:
------------
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() {}

spl_autoload_register('autoload2');

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

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

// unregister autoload2 - autoload1 _should_ be left behind
spl_autoload_unregister('autoload2');

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();

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-09 01:58 UTC] scottmac@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 20:01:57 2014 UTC