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.
This commit is contained in:
Tobias Oetiker 2018-09-12 14:11:44 +02:00 committed by GitHub
parent 8e871460a8
commit 8bccac1d07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)