From 94e52930e19533e5632cf62507ad4b8124d4c5da Mon Sep 17 00:00:00 2001 From: Nathan Glasl Date: Thu, 4 Feb 2016 09:47:00 +1100 Subject: [PATCH] Cleaning up the external URL behaviour when using a page redirect type. --- code/dataobjects/LinkMapping.php | 2 +- code/services/MisdirectionService.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/dataobjects/LinkMapping.php b/code/dataobjects/LinkMapping.php index 792e738..cdea46e 100644 --- a/code/dataobjects/LinkMapping.php +++ b/code/dataobjects/LinkMapping.php @@ -333,7 +333,7 @@ public function getLink() { // This is to support multiple sites, where the absolute page URLs are treated as relative. - return MisdirectionService::is_external_URL($link) ? HTTP::setGetVar('misdirected', true, ltrim($link, '/')) : $link; + return MisdirectionService::is_external_URL($link) ? ltrim($link, '/') : $link; } } else { diff --git a/code/services/MisdirectionService.php b/code/services/MisdirectionService.php index 91f706b..fb31a5a 100644 --- a/code/services/MisdirectionService.php +++ b/code/services/MisdirectionService.php @@ -176,9 +176,9 @@ public function getRecursiveMapping($map, $host = null, $testing = false) { $host = $map->getLinkHost(); } - // Determine the next link mapping. + // Determine the next link mapping, immediately redirecting towards an external URL. - while(!self::is_external_URL($redirect) && ($next = $this->getMapping($redirect, $host))) { + while((($map->RedirectType === 'Page') || !self::is_external_URL($redirect)) && ($next = $this->getMapping($redirect, $host))) { // Enforce a maximum number of redirects, preventing infinite recursion and inefficient link mappings.