From 5986dc9a0801e4f93ddb38e32f0d48ecc2cade68 Mon Sep 17 00:00:00 2001 From: ms-afk <58094448+ms-afk@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:26:41 +0200 Subject: [PATCH] fixed rare double execution of rewrite routes in exception handler If a rewrite route is present, Router's method handleException will, currently, be adding that route to the processedRoutes array without removing the hasPendingRewrite flag. This leads to the associated callback being executed twice if the callback itself returns NULL. This happens because the handleRouteRewrite method, finding that hasPendingRewrite is still set to true, adds the rewriteRoute to the processedRoutes for a second time, before finally setting that flag to false. --- src/Pecee/SimpleRouter/Router.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Pecee/SimpleRouter/Router.php b/src/Pecee/SimpleRouter/Router.php index fd2affa..8c88793 100644 --- a/src/Pecee/SimpleRouter/Router.php +++ b/src/Pecee/SimpleRouter/Router.php @@ -562,6 +562,7 @@ class Router if ($this->request->getRewriteRoute() !== null) { $this->processedRoutes[] = $this->request->getRewriteRoute(); + $this->request->setHasPendingRewrite(false); } return $this->routeRequest();