-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add $_GET['q'] #113
Add $_GET['q'] #113
Conversation
72f1d8a
to
78c3c8d
Compare
From $cid = $this->getRouteCollectionCacheId($request);
if ($cached = $this->cache->get($cid)) {
$this->currentPath->setPath($cached->data['path'], $request);
$request->query->replace($cached->data['query']);
return $cached->data['routes'];
}
else {
// Just trim on the right side.
$path = $request->getPathInfo();
$path = $path === '/' ? $path : rtrim($request->getPathInfo(), '/');
$path = $this->pathProcessor->processInbound($path, $request);
$this->currentPath->setPath($path, $request); So the current path is set when the route collection is resolved for the request. So we should remove the constructor logic. |
src/Path/CurrentPathStack.php
Outdated
public function getPath(?Request $request = null): string | ||
{ | ||
if (!isset($request)) { | ||
$request = $this->requestStack->getCurrentRequest(); | ||
} | ||
if (!isset($this->paths[$request])) { | ||
$this->paths[$request] = ['path' => $request->getPathInfo()]; | ||
} | ||
return $this->paths[$request]['path']; | ||
} | ||
|
||
public function setPath($path, ?Request $request = null): static | ||
{ | ||
if (!isset($request)) { | ||
$request = $this->requestStack->getCurrentRequest(); | ||
} | ||
$this->paths[$request] = ['path' => $path]; | ||
|
||
return $this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same logic as the parent, isn't it? It seems more likely that we just need setPath
to be
$_GET['q'] = $request->getPathInfo();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the same logic as the parent. Here we are working with a reference to $_GET['q'] so if D7 code changes $_GET['q'] it will also change D10’s current path.
729e34a
to
5d5b9af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question, just making sure I understand. Is the complexity to allow manipulating $_GET['q]
by reference in code? I thought the PR would entail just overriding setPath
to do $_GET['q'] = $path
Fixes #111.