FIX: Fixes #2110 added default Title value for saved pages. (#2366)

* FIX: Fixes #2110 added default Title value for saved pages.

* FIX: Fixes #2110 fixed linting and unit test failure

* BUG Rename default wording for untitled page
This commit is contained in:
ttunua 2019-04-15 14:33:15 +12:00 committed by Aaron Carlino
parent d4571d927d
commit 0b56a563c0
2 changed files with 10 additions and 1 deletions

View File

@ -1559,6 +1559,15 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
$this->URLSegment = "page-$this->ID";
}
}
// need to set the default values of a page e.g."Untitled [Page type]"
if (empty($this->Title)) {
$this->Title = _t(
'SilverStripe\\CMS\\Model\\SiteTree.UNTITLED',
'Untitled {pagetype}',
['pagetype' => $this->i18n_singular_name()]
);
};
// Ensure that this object has a non-conflicting URLSegment value.
$count = 2;

View File

@ -222,7 +222,7 @@ class SiteTreeTest extends SapphireTest
$obj->write();
$this->assertTrue($obj->publishRecursive());
$this->assertNull(DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = '$obj->ID'")->value());
$this->assertNotNull(DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = '$obj->ID'")->value());
}
public function testParentNodeCachedInMemory()