From a9f418abc3d8a5c76b13c3f66199f7871e0de234 Mon Sep 17 00:00:00 2001 From: Tobias Gaertner Date: Mon, 30 Jan 2023 10:44:25 +0100 Subject: [PATCH 1/3] [BUGFIX] Keep site base path on action call --- Classes/Action/OpcacheActionRequestFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Action/OpcacheActionRequestFactory.php b/Classes/Action/OpcacheActionRequestFactory.php index 6e4ec91..a34f9e5 100644 --- a/Classes/Action/OpcacheActionRequestFactory.php +++ b/Classes/Action/OpcacheActionRequestFactory.php @@ -32,7 +32,7 @@ public function createRequest(OpcacheAction $action): RequestInterface { foreach ($this->siteFinder->getAllSites() as $site) { $uri = $site->getRouter()->generateUri((string)$site->getRootPageId()); - $uri = $uri->withPath($action->getUriPath()); + $uri = $uri->withPath($uri->getPath() . $action->getUriPath()); $request = $this->requestFactory->createRequest($action->getRequestMethod(), $uri); $request = $this->requestSignature->sign($request); From 089293a660a98aa8442803cbf273972cc390f536 Mon Sep 17 00:00:00 2001 From: Tobias Gaertner Date: Tue, 31 Jan 2023 09:23:50 +0100 Subject: [PATCH 2/3] fix path detection for base urls with suffixed path --- Classes/Http/Middleware/OpcacheResetHandler.php | 4 +++- Classes/Http/Middleware/OpcacheStatusHandler.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Classes/Http/Middleware/OpcacheResetHandler.php b/Classes/Http/Middleware/OpcacheResetHandler.php index f6f1fa6..c2c2a2e 100644 --- a/Classes/Http/Middleware/OpcacheResetHandler.php +++ b/Classes/Http/Middleware/OpcacheResetHandler.php @@ -29,7 +29,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface { $action = new OpcacheAction(OpcacheAction::RESET); - if (strtolower($request->getMethod()) !== $action->getRequestMethod() || $request->getUri()->getPath() !== $action->getUriPath()) { + $resetPathDetected = substr_compare($request->getUri()->getPath(), $action->getUriPath(), -(strlen($action->getUriPath())), strlen($action->getUriPath())) === 0; + + if (strtolower($request->getMethod()) !== $action->getRequestMethod() || $resetPathDetected) { return $handler->handle($request); } diff --git a/Classes/Http/Middleware/OpcacheStatusHandler.php b/Classes/Http/Middleware/OpcacheStatusHandler.php index 4d032ce..f8a9820 100644 --- a/Classes/Http/Middleware/OpcacheStatusHandler.php +++ b/Classes/Http/Middleware/OpcacheStatusHandler.php @@ -29,7 +29,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface { $action = new OpcacheAction(OpcacheAction::STATUS); - if (strtolower($request->getMethod()) !== $action->getRequestMethod() || $request->getUri()->getPath() !== $action->getUriPath()) { + $statusPathDetected = substr_compare($request->getUri()->getPath(), $action->getUriPath(), -(strlen($action->getUriPath())), strlen($action->getUriPath())) === 0; + + if (strtolower($request->getMethod()) !== $action->getRequestMethod() || $statusPathDetected) { return $handler->handle($request); } From c362ae560323fa19c6e065fa6d65f2014b65dc69 Mon Sep 17 00:00:00 2001 From: Tobias Gaertner Date: Tue, 31 Jan 2023 09:52:10 +0100 Subject: [PATCH 3/3] [BUGFIX] negate condition in middleware correctly --- Classes/Http/Middleware/OpcacheResetHandler.php | 2 +- Classes/Http/Middleware/OpcacheStatusHandler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Http/Middleware/OpcacheResetHandler.php b/Classes/Http/Middleware/OpcacheResetHandler.php index c2c2a2e..9285d93 100644 --- a/Classes/Http/Middleware/OpcacheResetHandler.php +++ b/Classes/Http/Middleware/OpcacheResetHandler.php @@ -31,7 +31,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface $resetPathDetected = substr_compare($request->getUri()->getPath(), $action->getUriPath(), -(strlen($action->getUriPath())), strlen($action->getUriPath())) === 0; - if (strtolower($request->getMethod()) !== $action->getRequestMethod() || $resetPathDetected) { + if (strtolower($request->getMethod()) !== $action->getRequestMethod() || !$resetPathDetected) { return $handler->handle($request); } diff --git a/Classes/Http/Middleware/OpcacheStatusHandler.php b/Classes/Http/Middleware/OpcacheStatusHandler.php index f8a9820..0413918 100644 --- a/Classes/Http/Middleware/OpcacheStatusHandler.php +++ b/Classes/Http/Middleware/OpcacheStatusHandler.php @@ -31,7 +31,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface $statusPathDetected = substr_compare($request->getUri()->getPath(), $action->getUriPath(), -(strlen($action->getUriPath())), strlen($action->getUriPath())) === 0; - if (strtolower($request->getMethod()) !== $action->getRequestMethod() || $statusPathDetected) { + if (strtolower($request->getMethod()) !== $action->getRequestMethod() || !$statusPathDetected) { return $handler->handle($request); }