Merge pull request #2344 from creative-commoners/pulls/4.3/unsaved-dependent-relations

FIX Unsaved SiteTree records now return an empty list for DependentPages
This commit is contained in:
Guy Marriott 2018-12-03 11:48:54 +13:00 committed by GitHub
commit c1b1572752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

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

View File

@ -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');
}
}