Skip to content

Commit 5986dc9

Browse files
committed
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.
1 parent d3b1577 commit 5986dc9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Pecee/SimpleRouter/Router.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ protected function handleException(Exception $e): ?string
562562

563563
if ($this->request->getRewriteRoute() !== null) {
564564
$this->processedRoutes[] = $this->request->getRewriteRoute();
565+
$this->request->setHasPendingRewrite(false);
565566
}
566567

567568
return $this->routeRequest();

0 commit comments

Comments
 (0)