ID: 49618 User updated by: jost dot boekemeier at googlemail dot com Reported By: jost dot boekemeier at googlemail dot com Status: Bogus Bug Type: SPL related Operating System: Any PHP Version: 5.2.11 New Comment:
My code doesn't use __autoload. My code uses spl_autoloload. I have received a bug report because my code has destroyed an existing library. By issuing this bug report I have asked you to stop this, by either: * deprecating __autoload altogether * fix spl_autoload to honor an existing __autoload or * let library authors check for an existing (or upcoming) __autoload so that their library doesn't destroy existing code With the current behaviour I have no other choice but to not use spl_autoload at all, since I don't know whether the user will or will not include a library which uses __autoload later on. Previous Comments: ------------------------------------------------------------------------ [2009-09-22 09:11:12] [email protected] Thank you for your report. I do not think the behavior you describe is a bug. The documentation is clear about this: "If your code has an existing __autoload function then this function must be explicitly registered on the __autoload stack. This is because spl_autoload_register() will effectively replace the engine cache for the __autoload function by either spl_autoload() or spl_autoload_call()." Thus, calling spl_autoload_register() replaces __autoload(). ------------------------------------------------------------------------ [2009-09-22 05:24:02] jost dot boekemeier at googlemail dot com Description: ------------ The first call to spl_autoload_register destroys an existing __autoload hook. Please either deprecate __autoload and/or register __autoload with spl_autoload. Complete problem description is here: http://sourceforge.net/mailarchive/forum.php? thread_name=3afa16cf0909210312v3e102491n18701bcca0f5e030%40mail.gmail.com &forum_name=php-java-bridge-users Reproduce code: --------------- <?php function autoload_legacy($x) {echo "legacy "; return false;} function autoload_spl1($x) {echo "spl1 "; return false;} function autoload_spl2($x) {echo "spl2 "; return false;} function autoload_spl3($x) {echo "spl3 "; return false;} spl_autoload_register("autoload_spl1"); function __autoload($x) {return autoload_legacy($x);} spl_autoload_register("autoload_spl2"); spl_autoload_register("autoload_spl3"); @new Foo(); ?> Expected result: ---------------- spl1 spl2 spl3 legacy Actual result: -------------- spl1 spl2 spl3 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49618&edit=1
