From 4ff3e1d2ef8739fdfd5cdaadec21121ef103399d Mon Sep 17 00:00:00 2001 From: Sander Hagenaars Date: Mon, 27 Feb 2017 16:22:54 +0100 Subject: [PATCH] fixed bug caused by code ripped directly from Redirectorpage without being checked properly --- code/dataobjects/Block.php | 44 +++++++++++++------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/code/dataobjects/Block.php b/code/dataobjects/Block.php index 078620d..341aa0a 100644 --- a/code/dataobjects/Block.php +++ b/code/dataobjects/Block.php @@ -251,35 +251,21 @@ public function getCMSFields() * Return the link that we should redirect to. * Only return a value if there is a legal redirection destination. */ - public function getInternalExternalLink() - { - if ($this->RedirectionType == 'External') { - if ($this->ExternalURL) { - return $this->ExternalURL; - } - - } else { - $linkTo = $this->LinkToID ? DataObject::get_by_id("SiteTree", $this->LinkToID) : null; - - if ($linkTo) { - // We shouldn't point to ourselves - that would create an infinite loop! Return null since we have a - // bad configuration - if ($this->ID == $linkTo->ID) { - return null; - - // If we're linking to another redirectorpage then just return the URLSegment, to prevent a cycle of redirector - // pages from causing an infinite loop. Instead, they will cause a 30x redirection loop in the browser, but - // this can be handled sufficiently gracefully by the browser. - } elseif ($linkTo instanceof RedirectorPage) { - return $linkTo->regularLink(); - - // For all other pages, just return the link of the page. - } else { - return $linkTo->Link(); - } - } - } - } + public function getInternalExternalLink() + { + if ($this->RedirectionType == 'External') { + if ($this->ExternalURL) { + return $this->ExternalURL; + } + + } else { + $linkTo = $this->LinkToID ? DataObject::get_by_id("SiteTree", $this->LinkToID) : null; + + if ($linkTo) { + return $linkTo->Link(); + } + } + } function onBeforeWrite() {