Skip to content

Commit

Permalink
fixed bug caused by code ripped directly from Redirectorpage without …
Browse files Browse the repository at this point in the history
…being checked properly
  • Loading branch information
Sander Hagenaars authored and Sander Hagenaars committed Feb 27, 2017
1 parent f8f180f commit 4ff3e1d
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions code/dataobjects/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 4ff3e1d

Please sign in to comment.