From 24e190ea8265d16445a3210f7b06de191e474004 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Wed, 4 Oct 2017 16:59:53 +0100 Subject: [PATCH 1/4] Fix: TreeDropdownField showing broken page icons (fixes silverstripe/silverstripe-framework#7420) --- code/model/SiteTree.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index e8f6b8cb..de0c3f69 100755 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -2830,7 +2830,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } $flags = $this->getStatusFlags(); $treeTitle = sprintf( - "%s", + "%s", Convert::raw2htmlid($this->class), Convert::raw2att(Convert::raw2json($children)), Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle)) From fd39faeefd5241cf96313e968142183de767c51b Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 12 Oct 2017 14:40:48 +1100 Subject: [PATCH 2/4] BUG UploadField overwriteWarning isn't working in AssetAdmin When UploadField overwriteWarning is enabled, no overwrite warning message for uploading file in non-root folder. This fix will let CMSFileAddController know the current folder when 'fileexists' AJAX request is called. --- code/controllers/CMSFileAddController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/controllers/CMSFileAddController.php b/code/controllers/CMSFileAddController.php index ea7c5cb1..42273788 100644 --- a/code/controllers/CMSFileAddController.php +++ b/code/controllers/CMSFileAddController.php @@ -102,6 +102,11 @@ class CMSFileAddController extends LeftAndMain { ) ); $form->loadDataFrom($folder); + + if($this->currentPageID()){ + // Make sure this controller know current folder when AJAX 'fileexists' is fired. + $uploadField->setConfig('urlFileExists', Controller::join_links($uploadField->link('fileexists'), '?ID=' . $this->currentPageID())); + } $this->extend('updateEditForm', $form); From 9ae6fbffe16e89b447a955a9d0e2a7e697683155 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Mon, 16 Oct 2017 16:37:51 +1300 Subject: [PATCH 3/4] SiteTree check if in DB before delete children --- code/model/SiteTree.php | 2 +- tests/model/SiteTreeTest.php | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index de0c3f69..8319b5cf 100755 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -1574,7 +1574,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid parent::onBeforeDelete(); // If deleting this page, delete all its children. - if(SiteTree::config()->enforce_strict_hierarchy && $children = $this->AllChildren()) { + if($this->isInDB() && SiteTree::config()->enforce_strict_hierarchy && $children = $this->AllChildren()) { foreach($children as $child) { $child->delete(); } diff --git a/tests/model/SiteTreeTest.php b/tests/model/SiteTreeTest.php index 3ded8572..8f4ae262 100644 --- a/tests/model/SiteTreeTest.php +++ b/tests/model/SiteTreeTest.php @@ -276,7 +276,25 @@ class SiteTreeTest extends SapphireTest { } - public function testGetByLink() { + public function testNoCascadingDeleteWithoutID() { + Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true); + $count = SiteTree::get()->count(); + $this->assertNotEmpty($count); + $obj = new SiteTree(); + $this->assertFalse($obj->exists()); + $fail = true; + try { + $obj->delete(); + } catch (LogicException $e) { + $fail = false; + } + if ($fail) { + $this->fail('Failed to throw delete exception'); + } + $this->assertCount($count, SiteTree::get()); + } + + public function testGetByLink() { $home = $this->objFromFixture('Page', 'home'); $about = $this->objFromFixture('Page', 'about'); $staff = $this->objFromFixture('Page', 'staff'); From a73d5b4177be445128a6fa42e20dd8df13eaf554 Mon Sep 17 00:00:00 2001 From: Christopher Joe Date: Fri, 20 Oct 2017 10:01:56 +1300 Subject: [PATCH 4/4] FIX revert to this button after archiving --- code/controllers/CMSMain.php | 2 +- javascript/CMSMain.EditForm.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index c09d37e2..9e7aa924 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -1186,7 +1186,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $id = (isset($data['ID'])) ? (int) $data['ID'] : null; $version = (isset($data['Version'])) ? (int) $data['Version'] : null; - $record = DataObject::get_by_id($this->stat('tree_class'), $id); + $record = Versioned::get_latest_version($this->stat('tree_class'), $id); if($record && !$record->canEdit()) return Security::permissionFailure($this); if($version) { diff --git a/javascript/CMSMain.EditForm.js b/javascript/CMSMain.EditForm.js index 3d92f5f3..79925ff0 100644 --- a/javascript/CMSMain.EditForm.js +++ b/javascript/CMSMain.EditForm.js @@ -254,8 +254,7 @@ * * A "rollback" to a specific version needs user confirmation. */ - $('.cms-edit-form .Actions #Form_EditForm_action_rollback').entwine({ - + $('.cms-edit-form .Actions #Form_EditForm_action_doRollback').entwine({ /** * Function: onclick *