diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index b105b5c44..954c576a6 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -158,8 +158,8 @@ class SiteTree extends DataObject { */ protected function prepareCurrentAndSection() { if(!self::$currentPageID) { - self::$currentPageID = Director::currentPage()->ID; - if(!self::$currentPageID) { + self::$currentPageID = Director::currentPage() ? Director::currentPage()->ID : null; + if(!isset(self::$currentPageID)) { self::$currentPageID = -1; $nextID = isset(Director::currentPage()->Parent->ID) ? Director::currentPage()->Parent->ID : null; } else {