Uh oh!
There was an error while loading. Please reload this page.
feat: add SiteURIFactory - #7256
Conversation
Uh oh!
There was an error while loading. Please reload this page.
77d43a8 to
e1d9a9cCompare157d9cb to
d68e8acCompareb629857 to
b5308b0Compareb5308b0 to
3079cd9Compare| private function updateServer(string $key, string $value): void | ||
| { | ||
| $_SERVER[$key] = $value; | ||
| } | ||
| private function updateGetArray(array $array): void | ||
| { | ||
| $_GET = $array; | ||
| } |
There was a problem hiding this comment.
These make me pretty uneasy. What about an external service dependency that handles Globals, so it can be mocked or replaced? This behavior within a Factory is very counterintuitive.
There was a problem hiding this comment.
What do you mean?
Adding another class that handles globals?
private$superglobals;
privatefunctionupdateServer(string$key, string$value): void
{
$this->superglobals->setServer($key, $value);
}There was a problem hiding this comment.
Yes, precisely. It could be adapted to anywhere else in the framework we touch globals.
239b2cc to
61beca5Compare| // Strip the SCRIPT_NAME path from the URI | ||
| if ( | ||
| $path !== '' && isset($this->superglobals->server('SCRIPT_NAME')[0]) |
There was a problem hiding this comment.
isset($this->superglobals->server('SCRIPT_NAME')[0])
What is this condition checked?$_SERVER['SCRIPT_NAME'] is a string.
The condition comes from:
CodeIgniter4/system/HTTP/IncomingRequest.php
Lines 282 to 286 in 6cedbe9
And it came from:
bcit-ci/CodeIgniter@ead327f7
There was a problem hiding this comment.
Does that end up being translated as this, because of string array access?
$_SERVER['SCRIPT_NAME'] !== ''There was a problem hiding this comment.
Yes. I assume this is unintended but that's the equivalence.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Because it might be false.
It is difficult to understand.
Needs #7252Description
Supersedes #7239
Add
SiteURIFactoryto create the current URI object.To create the current URI object before the Request object creation.
Also, to remove all URI adjustment processing currently performed in the constructor of the Request object.
This PR does not change any existing features yet. The next #7282 changes the behavior.
SiteURIFactory::createFromGlobals()SuperglobalsChecklist: