|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-10-15 02:30 UTC] laruence@php.net
[2017-10-15 02:30 UTC] laruence@php.net
-Status: Open
+Status: Closed
[2017-12-01 14:11 UTC] weirdan at gmail dot com
[2018-01-12 17:19 UTC] nikic@php.net
[2018-01-12 17:20 UTC] nikic@php.net
-Status: Closed
+Status: Re-Opened
[2018-01-12 17:20 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 08:00:01 2025 UTC |
Description: ------------ Hi, PHP's built-in webserver crashes if it's started with a router script with relative path and in a shutdown function there is a chdir to a different directory than one where the router script is. Test script: --------------- Create the file /home/user/router.php with the following content <?php function shutdownWithChdir() { chdir('/tmp'); } register_shutdown_function('shutdownWithChdir'); echo 'Hello World'; ?> Now in your terminal: $ cd /home/user $ php -S localhost:3000 router.php Now perform the first request to the webserver and see that correctly returns "Hello World". Then perform a second request. Expected result: ---------------- You would expect to get "Hello World" even for the second request. Actual result: -------------- Instead you get: Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required 'router.php' (include_path='.:') in Unknown on line 0 For every subsequent request. If you restart the webserver you'll get the same result: first request ok, subsequent requests error. This happens only if the chdir is done inside a "shutdown function" not if it's done in the "normal" script execution. I can confirm this bug on PHP 5.6, 7.0 and 7.1 (I do not remember the exact versions numbers) and I don't think it's related to the #74496.