From 0b56a563c0b6f51cc94589b12693c5326f0c878c Mon Sep 17 00:00:00 2001 From: ttunua Date: Mon, 15 Apr 2019 14:33:15 +1200 Subject: [PATCH] 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 --- code/Model/SiteTree.php | 9 +++++++++ tests/php/Model/SiteTreeTest.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 0712e821..f0c768cf 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -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; diff --git a/tests/php/Model/SiteTreeTest.php b/tests/php/Model/SiteTreeTest.php index 9183406d..0aa2db16 100644 --- a/tests/php/Model/SiteTreeTest.php +++ b/tests/php/Model/SiteTreeTest.php @@ -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()