php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74496 php -S fail to handle correctly router and docroot relative path
Submitted: 2017-04-25 10:46 UTC Modified: -
Votes:3
Avg. Score:1.7 ± 0.9
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: evaisse at gmail dot com Assigned:
Status: Open Package: Built-in web server
PHP Version: 5.6.30 OS: Mac OS X 10.12.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
21 + 14 = ?
Subscribe to this entry?

 
 [2017-04-25 10:46 UTC] evaisse at gmail dot com
Description:
------------
https://phpbugs-embeddedserver-ttohstztwy.now.sh/_src/?f=Dockerfile

If I provide a ./router.php file & a docroot ./public

The server works as expected until I receiving a fatal error in a php script (e.g. ./public/kill.php). 

Then the server is stuck to the following error for all PHP scripts : 

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

Note the bug is produced only if the router.php file provide a "return false;" statement on PHP script. If I handle php script via include (e.g. ./router-fix.php), everything works as expected.

Test script:
---------------
<?php
/** 
 * 
 * Run with RELATIVE paths
 * 
 * $ php -S 127.0.0.1:8089 -t ./public router.php
 * 
 * then go to /script-that-produce-a-fatal.php
 * 
 * Next hit on php script will produce strange error.
 */

$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);


if ($uri !== '/' && file_exists(__DIR__.'/public/'.$uri)) {
    return false;
} else {
    return readfile(__DIR__ . '/public/index.html');
}

Expected result:
----------------
Then the server is stuck to the following error for all PHP scripts : 

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC