Fix the use of route values using a PSR request
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Apr 2023 13:13:27 +0000 (15:13 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Apr 2023 13:13:27 +0000 (15:13 +0200)
wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index 55cd8f1fc920e8cfac6755d6923fdb8897f10e32..f8f0abca23f2cd90b47edf1d6c91c15ccb3b9387 100644 (file)
@@ -79,6 +79,10 @@ final class RequestHandler extends SingletonFactory
         try {
             $this->isACPRequest = $isACPRequest;
 
+            // This must be called before the PSR request is created, because it registers the
+            // route paramters in $_GET.
+            $routeMatches = RouteHandler::getInstance()->matches();
+
             try {
                 $psrRequest = ServerRequestFactory::fromGlobals(
                     null, // $_SERVER
@@ -102,7 +106,7 @@ final class RequestHandler extends SingletonFactory
                 throw new NamedUserException('Failed to parse the incoming request.', 0, $e);
             }
 
-            if (RouteHandler::getInstance()->matches()) {
+            if ($routeMatches) {
                 $builtRequest = $this->buildRequest($psrRequest, $application);
             } else {
                 if (ENABLE_DEBUG_MODE) {