diff --git a/src/Routing/Filter/RoutingFilter.php b/src/Routing/Filter/RoutingFilter.php index faea2cd2fa9..293f627eb84 100644 --- a/src/Routing/Filter/RoutingFilter.php +++ b/src/Routing/Filter/RoutingFilter.php @@ -58,6 +58,7 @@ public function beforeDispatch(Event $event) $request->addParams($params); } } catch (RedirectException $e) { + $event->stopPropagation(); $response = $event->data['response']; $response->statusCode($e->getCode()); $response->header('Location', $e->getMessage()); diff --git a/tests/TestCase/Routing/Filter/RoutingFilterTest.php b/tests/TestCase/Routing/Filter/RoutingFilterTest.php index b8f73c8e45b..58be6b85c25 100644 --- a/tests/TestCase/Routing/Filter/RoutingFilterTest.php +++ b/tests/TestCase/Routing/Filter/RoutingFilterTest.php @@ -90,6 +90,7 @@ public function testBeforeDispatchRedirectRoute() $this->assertInstanceOf('Cake\Network\Response', $response); $this->assertSame('http://localhost/articles', $response->header()['Location']); $this->assertSame(301, $response->statusCode()); + $this->assertTrue($event->isStopped()); } /**