diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 3280a26d..c592a24c 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -1779,7 +1779,12 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi } // Content links - $items = new ArrayList(); + $items = ArrayList::create(); + + // If the record hasn't been written yet, it cannot be depended on yet + if (!$this->isInDB()) { + return $items; + } // We merge all into a regular SS_List, because DataList doesn't support merge if ($contentLinks = $this->BackLinkTracking()) { diff --git a/tests/php/Model/SiteTreeTest.php b/tests/php/Model/SiteTreeTest.php index dcfe1a58..ad10ccb8 100644 --- a/tests/php/Model/SiteTreeTest.php +++ b/tests/php/Model/SiteTreeTest.php @@ -1576,4 +1576,11 @@ class SiteTreeTest extends SapphireTest $title = $siteTree->getTreeTitle(); $this->assertNotNull($title); } + + public function testDependentPagesOnUnsavedRecord() + { + $record = new SiteTree(); + $pages = $record->DependentPages(); + $this->assertCount(0, $pages, 'Unsaved pages should have no dependent pages'); + } }