From 1d61bf7100b34d30c0af807c9b61b65a19705162 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 13 Oct 2010 01:24:53 +0000 Subject: [PATCH] BUGFIX Prevent handling of controller actions which return $this avoid infinite loops in RequestHandler->handleRequest (thanks Hamish!) (from r102004) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112054 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/RequestHandler.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/control/RequestHandler.php b/core/control/RequestHandler.php index 74633a386..c2e067153 100755 --- a/core/control/RequestHandler.php +++ b/core/control/RequestHandler.php @@ -145,9 +145,10 @@ class RequestHandler extends ViewableData { } // If we return a RequestHandler, call handleRequest() on that, even if there is no more URL to parse. - // It might have its own handler. However, we only do this if we haven't just parsed an empty rule ourselves, - // to prevent infinite loops - if(!$request->isEmptyPattern($rule) && is_object($result) && $result instanceof RequestHandler) { + // It might have its own handler. However, we only do this if we haven't just parsed an empty rule ourselves, + // to prevent infinite loops. Also prevent further handling of controller actions which return themselves + // to avoid infinite loops. + if($this !== $result && !$request->isEmptyPattern($rule) && is_object($result) && $result instanceof RequestHandler) { $returnValue = $result->handleRequest($request); // Array results can be used to handle