MFH Fix bug #48493 - spl_autoload_register can leave the HT in an inconsistent way.

Need to point the second elements previous item to head so we can traverse upwards.
This commit is contained in:
Scott MacVicar 2009-06-09 01:58:07 +00:00
parent cf1a08e317
commit fc8426ad31
2 changed files with 27 additions and 0 deletions

View File

@ -415,6 +415,7 @@ PHP_FUNCTION(spl_autoload_call)
(ht)->pListTail->pListNext = (ht)->pListHead; \
(ht)->pListHead = (ht)->pListTail; \
(ht)->pListTail = (ht)->pListHead->pListLast; \
(ht)->pListHead->pListNext->pListLast = (ht)->pListHead;\
(ht)->pListTail->pListNext = NULL; \
(ht)->pListHead->pListLast = NULL;

View File

@ -0,0 +1,26 @@
--TEST--
SPL: Bug #48493 spl_autoload_unregister() can't handle prepended functions
--FILE--
<?php
function autoload1() {}
function autoload2() {}
spl_autoload_register('autoload2');
spl_autoload_register('autoload1', true, true);
var_dump(spl_autoload_functions());
spl_autoload_unregister('autoload2');
var_dump(spl_autoload_functions());
?>
--EXPECT--
array(2) {
[0]=>
string(9) "autoload1"
[1]=>
string(9) "autoload2"
}
array(1) {
[0]=>
string(9) "autoload1"
}