mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX Unsaved SiteTree records now return an empty list for DependentPages
This commit is contained in:
parent
309dc97a32
commit
0bb22732c9
@ -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()) {
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user