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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: evaisse at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC