From 7769f03ccc0300510daffdfe2bce7723f2193ee1 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 14 Mar 2016 08:36:47 +1300 Subject: [PATCH] BUG Remove duplicate extension hook Fixes #5170 Reverts #3355 --- control/Controller.php | 19 +++++++++++++++---- control/RequestHandler.php | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/control/Controller.php b/control/Controller.php index bafba0828..d198bc30c 100644 --- a/control/Controller.php +++ b/control/Controller.php @@ -197,8 +197,6 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { * @return HTMLText|SS_HTTPResponse */ protected function handleAction($request, $action) { - $this->extend('beforeCallActionHandler', $request, $action); - foreach($request->latestParams() as $k => $v) { if($v || !isset($this->urlParams[$k])) $this->urlParams[$k] = $v; } @@ -215,9 +213,22 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { } else { return $result; } - } else { - return $this->getViewer($action)->process($this); } + + // Fall back to index action with before/after handlers + $beforeResult = $this->extend('beforeCallActionHandler', $request, $action); + if ($beforeResult) { + return reset($beforeResult); + } + + $result = $this->getViewer($action)->process($this); + + $afterResult = $this->extend('afterCallActionHandler', $request, $action, $result); + if($afterResult) { + return reset($afterResult); + } + + return $result; } /** diff --git a/control/RequestHandler.php b/control/RequestHandler.php index df6552180..6f66a0f0b 100644 --- a/control/RequestHandler.php +++ b/control/RequestHandler.php @@ -287,7 +287,7 @@ class RequestHandler extends ViewableData { $actionRes = $this->$action($request); - $res = $this->extend('afterCallActionHandler', $request, $action); + $res = $this->extend('afterCallActionHandler', $request, $action, $actionRes); if ($res) return reset($res); return $actionRes;