From 8bccac1d07e49803c67bc95ce11c105343f79368 Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Wed, 12 Sep 2018 14:11:44 +0200 Subject: [PATCH] do not die if there is no parent in RelativeLink When resolving a relative link it can be that no valid parent node is reached ... handle this condition gracefully. --- code/model/SiteTree.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index 9e722cc1..d7d8ac4c 100755 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -519,7 +519,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if((!$parent || !$parent->exists()) && $this->IsDeletedFromStage) { $parent = Versioned::get_latest_version('SiteTree', $this->ParentID); } - $base = $parent->RelativeLink($this->URLSegment); + $base = $parent ? $parent->RelativeLink($this->URLSegment) : null; } elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) { // Unset base for root-level homepages. // Note: Homepages with action parameters (or $action === true)