Bug #75369 [NEW]: spl_autoload_register prepend not working with nested require_once

From: Date: Thu, 12 Oct 2017 20:13:52 +0000
Subject: Bug #75369 [NEW]: spl_autoload_register prepend not working with nested require_once
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211659@lists.php.net to get a copy of this message
From: tbollinger at ivesinc dot com Operating system: PHP version: 7.1.10 Package: SPL related Bug Type: Bug Bug description:spl_autoload_register prepend not working with nested require_once Description: ------------ This bug requires three files to reproduce, since it is an issue with spl_autoload_register(), specifically the prepend argument, and require_once(). Removing the prepend argument displays the expected result. This was created using a base install of PHP 7.1.10. Test script: --------------- ---- file1.php ---- <?php function load() { spl_autoload_register('foo'); } function foo($class) { echo __FUNCTION__ . "\n"; require_once('./file2.php'); } load(); new FooBar(); ---- file2.php ---- <?php function bar($class) { echo __FUNCTION__ . "\n"; require_once('./file3.php'); } spl_autoload_register('bar', true, true); ---- file3.php ---- <?php class FooBar { public function __construct() { echo __CLASS__ . "\n"; } } Expected result: ---------------- foo bar FooBar Actual result: -------------- foo foo PHP Fatal error: Uncaught Error: Class 'FooBar' not found in /home/user/phptest/file1.php:5 Stack trace: #0 {main} thrown in /home/user/phptest/file1.php on line 5 -- Edit bug report at https://bugs.php.net/bug.php?id=75369&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75369&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75369&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75369&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75369&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75369&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75369&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75369&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75369&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75369&r=support Expected behavior: https://bugs.php.net/fix.php?id=75369&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75369&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75369&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75369&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75369&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75369&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75369&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75369&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75369&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75369&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75369&r=mysqlcfg

« previous php.bugs (#211659) next »