[Bug]: Herd does not support $_SERVER['PATH_INFO]
Platform
Any
Operating system version
Any
System architecture
Any
Herd Version
Any
PHP Version
No response
Bug description
Any page that uses $_SERVER['PATH_INFO] does not work under Herd because the startup scripts looks for the wrong file name and any path info added after the script marks the page as a Page Not Found
I would expect the PATH_INFO content to be added to the path of the launched page.
Steps to reproduce
Create a test page test.php
<?php
echo $_SERVER['PATH_INFO'];
And launch it as test.php/PATH/INFO/GOES/HERE?param=123
Expected result: PATH/INFO/GOES/HERE printed to page, this is what is printed on any web server (some don't pass the PATH_INFO but it can be obtained).
Obtained result: blank page / page not found. Herd / Valet incorrectly looks for existance of the file test.php/PATH/INFO/GOES/HERE
Relevant log output
I have a patch for this and a script that applies the patch to server.php
At the beginning of server.php:
$_SERVER['ORIGINAL_REQUEST_URI'] = $_SERVER['REQUEST_URI'];
$uri = $_SERVER['REQUEST_URI'];
$path = parse_url($uri, PHP_URL_PATH);
$needsPatch = (substr($path, -strlen($_SERVER['PATH_INFO'])) == $_SERVER['PATH_INFO']);
if ($needsPatch) {
$endOfUrl = substr($_SERVER['REQUEST_URI'], strlen($path));
$patchedPath = substr($path, 0, -strlen($_SERVER['PATH_INFO']));
$_SERVER['REQUEST_URI'] = $patchedPath . $endOfUrl;
}
and at the end of server.php, just before the require $frontControllerPath:
$_SERVER['REQUEST_URI'] = $_SERVER['ORIGINAL_REQUEST_URI'];
This will apply the patch creating two files and adding two lines to the server.php script. Remove .txt from end of file. patch_per_herd.php.txt