Description
Symfony version(s) affected: 5.1.2
Description
- My document root is
/var/www/photos/public
. - front controller at
/var/www/photos/public/index.php
. - I try to request a path called
/php/index.php
(it's a route with this exact path).
I have the following parameters in my $_SERVER
:
[
"DOCUMENT_ROOT" => "/var/www/photos/public",
"DOCUMENT_URI" => "index.php",
"PATH_INFO" => "",
"PHP_SELF" => "index.php",
"REQUEST_URI" => "/php/index.php",
"SCRIPT_FILENAME" => "/var/www/photos/public/index.php",
"SCRIPT_NAME" => "index.php",
]
So, as the app is installed directly under the domain, the base url should always be empty.
However.. as this (see below) will never be true (as the base is index.php
, as well as the base of the request url), it will always be set incorrectly.
How to reproduce
This would be a (currently failing) test case to handle this issue:
use Symfony\Component\HttpFoundation\Request;
$request = new Request(
$query = [],
$request = [],
$attributes = [],
$cookies = [],
$files = [],
$server = [
"DOCUMENT_ROOT" => "/var/www/photos/public",
"DOCUMENT_URI" => "index.php",
"PATH_INFO" => "",
"PHP_SELF" => "index.php",
"REQUEST_URI" => "/php/index.php",
"SCRIPT_FILENAME" => "/var/www/photos/public/index.php",
"SCRIPT_NAME" => "index.php",
]
);
assert("" === $request->getBaseUrl());
Please note that if you change the REQUEST_URI
above to "REQUEST_URI" => "/php/index2.php",
it will work correctly.
Possible Solution
I have absolutely no overview around all the weird edge cases of this exact method, I only know that this is an issue and it should possibly be fixed?
Sorry to deliver another edge case :(
Additional context
—