Move the “exception escapes from middleware” detection further out
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Apr 2023 12:41:23 +0000 (14:41 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Apr 2023 12:41:23 +0000 (14:41 +0200)
Since abd060c56250c1a340732b8180c90efd49727ee9 there should not be such an
exception even during routing, not just after the middleware stack terminates.

wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index 8e8e602250cefb276b88e86244d8e7703f6bd465..0b511b0c230890fe1d43b93b427d5a69e9d70007 100644 (file)
@@ -137,14 +137,7 @@ final class RequestHandler extends SingletonFactory
                     new HandleValinorMappingErrors(),
                 ]);
 
-                try {
-                    $response = $pipeline->process($psrRequest, $this->getActiveRequest());
-                } catch (IllegalLinkException | PermissionDeniedException | InvalidSecurityTokenException $e) {
-                    throw new \LogicException(\sprintf(
-                        "'%s' escaped from the middleware stack.",
-                        $e::class
-                    ), 0, $e);
-                }
+                $response = $pipeline->process($psrRequest, $this->getActiveRequest());
 
                 if ($response instanceof LegacyPlaceholderResponse) {
                     return;
@@ -156,6 +149,11 @@ final class RequestHandler extends SingletonFactory
 
             $emitter = new SapiEmitter();
             $emitter->emit($response);
+        } catch (IllegalLinkException | PermissionDeniedException | InvalidSecurityTokenException $e) {
+            throw new \LogicException(\sprintf(
+                "'%s' escaped from the middleware stack.",
+                $e::class
+            ), 0, $e);
         } catch (NamedUserException $e) {
             $e->show();