#40091 [Opn->Csd]: spl_autoload_register with 2 instances of the same class
| From: | iliaa@php.net | Date: | Wed, 10 Jan 2007 18:14:45 +0000 |
| Subject: | #40091 [Opn->Csd]: spl_autoload_register with 2 instances of the same class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-107437@lists.php.net to get a copy of this message | ||
ID: 40091
Updated by: iliaa@php.net
Reported By: dweller at devonweller dot com
-Status: Open
+Status: Closed
Bug Type: SPL related
Operating System: Mac OS X
PHP Version: 5.2.0
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2007-01-10 15:20:23] dweller at devonweller dot com
Description:
------------
When using spl_autoload_register with two instances of the same class
name, the autoload stack only stores one function callback instead of
two.
Reproduce code:
---------------
class MyAutoloader {
function __construct($directory_to_use) {}
function autoload($class_name) {
// code to autoload based on directory
}
}
$autloader1 = new MyAutoloader('dir1');
spl_autoload_register(array($autloader1, 'autoload'));
$autloader2 = new MyAutoloader('dir2');
spl_autoload_register(array($autloader2, 'autoload'));
print_r(spl_autoload_functions());
Expected result:
----------------
Array
(
[0] => Array
(
[0] => MyAutoloader
[1] => autoload
)
[1] => Array
(
[0] => MyAutoloader
[1] => autoload
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[0] => MyAutoloader
[1] => autoload
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40091&edit=1