Bug #75647 [Dup]: `-t dir` changed behavior when combined with a router file

From: Date: Thu, 07 Dec 2017 15:36:56 +0000
Subject: Bug #75647 [Dup]: `-t dir` changed behavior when combined with a router file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212998@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75647&edit=1 ID: 75647 Updated by: nikic@php.net Reported by: martin dot st at wolke7 dot net Summary: -t dir changed behavior when combined with a router file Status: Duplicate Type: Bug Package: Built-in web server Operating System: Linux PHP Version: 7.1.12 Block user comment: N Private report: N New Comment: @requinix: The commit shows that this was an unintended side-effect of another fix. It should be reverted, because it's an unnecessary BC break for a case where the new behavior doesn't even make sense. Paths provided on the CLI should be interpreted relative to the CLI CWD... Previous Comments: ------------------------------------------------------------------------ [2017-12-07 15:26:59] requinix@php.net No, not "more or less". It is intentional and the commit clearly shows it as such. ------------------------------------------------------------------------ [2017-12-07 15:22:59] requinix@php.net That is indeed the right commit. However it's more or less an intentional change: the router script is now relative to the document root and not the current directory. An absolute path will work too, of course. See bug #75604. $ php -S localhost:8000 -t directory router.php $ php -S localhost:8000 -t directory pwd/directory/router.php ------------------------------------------------------------------------ [2017-12-07 15:09:00] martin dot st at wolke7 dot net Description: ------------ This is my first bug report to PHP, so please don't be mad at me. The following command used to work fine but stopped working in PHP 7.1.12 php -S localhost:8000 -t directory directory/router.php It seems like somebody changed the way relative paths are handled when using the -t option and a router file at the same time. This statement also shows how this was working 3 months ago: http://php.net/manual/en/features.commandline.webserver.php#121501 I think it might be related to the following commit, but I'm not very sure (I'm not a C developer): http://git.php.net/?p=php-src.git;a=commit;h=816758eda2bcdd69ba505fb6bbb79124a7bf2254 What actually happens --------------------- Starting the server works nicely: $ php -S localhost:8000 -t directory directory/router.php PHP 7.1.12 Development Server started at Thu Dec 7 15:00:15 2017 Listening on http://localhost:8000 Document root is [/home/myuser/mycode/directory] Press Ctrl-C to quit. When a request comes in, I get a message like the following (both in the result and in the server output): [Thu Dec 7 15:00:21 2017] PHP Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 [Thu Dec 7 15:00:21 2017] PHP Fatal error: Unknown: Failed opening required '/home/myuser/mycode/directory/directory/router.php' (include_path='.:/home/rof/.phpenv/versions/7.1.12/lib/php/pear') in Unknown on line 0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75647&edit=1

« previous php.bugs (#212998) next »