From 7f52067771a0fe8b9de7c1eec09d56bb5313c790 Mon Sep 17 00:00:00 2001 From: Nathan Glasl Date: Thu, 25 Feb 2016 13:37:45 +1100 Subject: [PATCH] The current controller is now only retrieved once. --- code/services/MisdirectionService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/services/MisdirectionService.php b/code/services/MisdirectionService.php index a07ae92..f8d35f6 100644 --- a/code/services/MisdirectionService.php +++ b/code/services/MisdirectionService.php @@ -76,8 +76,8 @@ public function getMapping($URL, $host = null) { // Enforce any hostname restriction that may have been defined. - if(is_null($host) && Controller::curr()) { - $host = Controller::curr()->getRequest()->getHeader('Host'); + if(is_null($host) && ($controller = Controller::curr())) { + $host = $controller->getRequest()->getHeader('Host'); } $matches = $matches->where("(HostnameRestriction IS NULL) OR (HostnameRestriction = '" . Convert::raw2sql($host) . "')"); $regex = clone $matches;