From 24e190ea8265d16445a3210f7b06de191e474004 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Wed, 4 Oct 2017 16:59:53 +0100 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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 * From 9e31c3240bf44134fd51d46099d96618dda103ca Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Wed, 25 Oct 2017 17:58:53 +0100 Subject: [PATCH 05/10] Add composer autoloading support to 3.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5e6db2e6..20b92514 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ } }, "autoload": { - "classmap": ["tests/behat/"] + "classmap": ["tests/behat/", "code"] }, "minimum-stability": "dev" } From 8de154d92cc9b044824205216683c0a187d17e5b Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 16 Nov 2017 14:43:32 +1300 Subject: [PATCH 06/10] BUG Restore missing '(Choose Page)' text in link insert modal --- code/Forms/InternalLinkFormFactory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/Forms/InternalLinkFormFactory.php b/code/Forms/InternalLinkFormFactory.php index 2338a578..ba97c280 100644 --- a/code/Forms/InternalLinkFormFactory.php +++ b/code/Forms/InternalLinkFormFactory.php @@ -31,7 +31,9 @@ class InternalLinkFormFactory extends LinkFormFactory SiteTree::class, 'ID', 'TreeTitle' - )->setTitleField('MenuTitle'), + ) + ->setTitleField('MenuTitle') + ->setHasEmptyDefault(true), TextField::create( 'Description', _t(__CLASS__.'.LINKDESCR', 'Link description') From 39edaedc8f6736e26d40e0b05f2f8cd080e447bb Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Fri, 17 Nov 2017 11:45:41 +0000 Subject: [PATCH 07/10] Loosen PHPUnit constraints --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 20b92514..94135c1d 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,9 @@ "silverstripe/reports": "~3.4", "silverstripe/siteconfig": "~3.4" }, + "require-dev": { + "phpunit/phpunit": "^3 || ^4 || ^5" + }, "extra": { "branch-alias": { "3.x-dev": "3.6.x-dev" From 694d2589579f944ec714dac6aff7b888e5c42a96 Mon Sep 17 00:00:00 2001 From: Christopher Joe Date: Mon, 20 Nov 2017 09:17:22 +1300 Subject: [PATCH 08/10] BUG Fix allowed children types now load properly --- client/dist/js/bundle.js | 2 +- client/src/legacy/CMSMain.AddForm.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/dist/js/bundle.js b/client/dist/js/bundle.js index 6680e7e9..81b79945 100644 --- a/client/dist/js/bundle.js +++ b/client/dist/js/bundle.js @@ -1 +1 @@ -!function(t){function e(a){if(n[a])return n[a].exports;var i=n[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,a){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:a})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=22)}([function(t,e){t.exports=jQuery},function(t,e){t.exports=i18n},function(t,e){t.exports=Injector},function(t,e){t.exports=React},,,,,,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={ANCHORSELECTOR_UPDATED:"ANCHORSELECTOR_UPDATED",ANCHORSELECTOR_UPDATING:"ANCHORSELECTOR_UPDATING",ANCHORSELECTOR_UPDATE_FAILED:"ANCHORSELECTOR_UPDATE_FAILED"}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={SUCCESS:"SUCCESS",DIRTY:"DIRTY",UPDATING:"UPDATING",FAILED:"FAILED"}},function(t,e){t.exports=Redux},function(t,e,n){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}var i=n(21),r=a(i),o=n(20),s=a(o);window.document.addEventListener("DOMContentLoaded",function(){(0,s.default)(),(0,r.default)()})},function(t,e,n){"use strict";var a=n(0);(function(t){return t&&t.__esModule?t:{default:t}})(a).default.entwine("ss",function(t){t(".TreeDropdownField").entwine({OldValue:null}),t("#Form_AddForm_ParentID_Holder .treedropdownfield").entwine({onmatch:function(){this._super(),t(".cms-add-form").updateTypeList()}}),t(".cms-add-form .parent-mode :input").entwine({onclick:function(t){var e=this.closest("form").find("#Form_AddForm_ParentID_Holder .TreeDropdownField");"top"==this.val()?(e.setOldValue(e.getValue()),e.setValue(0)):(e.setValue(e.getOldValue()||0),e.setOldValue(null)),e.refresh(),e.trigger("change")}}),t(".cms-add-form").entwine({ParentCache:{},onadd:function(){var e=this;this.find("#Form_AddForm_ParentID_Holder .TreeDropdownField").bind("change",function(){e.updateTypeList()}),this.find(".SelectionGroup.parent-mode").bind("change",function(){e.updateTypeList()}),"top"==t(".cms-add-form .parent-mode :input").val()&&this.updateTypeList()},loadCachedChildren:function(t){var e=this.getParentCache();return void 0!==e[t]?e[t]:null},saveCachedChildren:function(t,e){var n=this.getParentCache();n[t]=e,this.setParentCache(n)},updateTypeList:function(){var e=this.data("hints"),n=this.find("#Form_AddForm_ParentID_Holder .TreeDropdownField"),a=this.find("input[name=ParentModeField]:checked").val(),i=n.data("metadata"),r=i&&"child"===a?n.getValue():null,o=i?i.ClassName:null,s=o&&"child"===a&&r?o:"Root",d=void 0!==e[s]?e[s]:null,l=this,u=d&&void 0!==d.defaultChild?d.defaultChild:null,c=[];if(r){if(this.hasClass("loading"))return;return this.addClass("loading"),null!==(c=this.loadCachedChildren(r))?(this.updateSelectionFilter(c,u),void this.removeClass("loading")):(t.ajax({url:l.data("childfilter"),data:{ParentID:r},success:function(t){l.saveCachedChildren(r,t),l.updateSelectionFilter(t,u)},complete:function(){l.removeClass("loading")}}),!1)}c=d&&void 0!==d.disallowedChildren?d.disallowedChildren:[],this.updateSelectionFilter(c,u)},updateSelectionFilter:function(e,n){var a=null;if(this.find("#Form_AddForm_PageType div.radio").each(function(){var n=t(this).find("input").val(),i=-1===t.inArray(n,e);t(this).setEnabled(i),i||t(this).setSelected(!1),a=null===a?i:a&&i}),n)var i=this.find("#Form_AddForm_PageType div.radio input[value="+n+"]").parents("li:first");else var i=this.find("#Form_AddForm_PageType div.radio:not(.disabled):first");i.setSelected(!0),i.siblings().setSelected(!1),this.find("#Form_AddForm_PageType div.radio:not(.disabled)").length?this.find("button[name=action_doAdd]").removeAttr("disabled"):this.find("button[name=action_doAdd]").attr("disabled","disabled"),this.find(".message-restricted")[a?"hide":"show"]()}}),t(".cms-add-form #Form_AddForm_PageType div.radio").entwine({onclick:function(t){this.setSelected(!0)},setSelected:function(t){var e=this.find("input");t&&!e.is(":disabled")?(this.siblings().setSelected(!1),this.toggleClass("selected",!0),e.prop("checked",!0)):(this.toggleClass("selected",!1),e.prop("checked",!1))},setEnabled:function(e){t(this).toggleClass("disabled",!e),e?t(this).find("input").removeAttr("disabled"):t(this).find("input").attr("disabled","disabled").removeAttr("checked")}}),t(".cms-content-addpage-button").entwine({onclick:function(e){var n,a=t(".cms-tree"),i=t(".cms-list"),r=0;if(a.is(":visible")){var o=a.jstree("get_selected");r=o?t(o[0]).data("id"):null}else{var s=i.find('input[name="Page[GridState]"]').val();s&&(r=parseInt(JSON.parse(s).ParentID,10))}var d,l={selector:this.data("targetPanel"),pjax:this.data("pjax")};r?(n=this.data("extraParams")?this.data("extraParams"):"",d=t.path.addSearchParams(i18n.sprintf(this.data("urlAddpage"),r),n)):d=this.attr("href"),t(".cms-container").loadPanel(d,null,l),e.preventDefault(),this.blur()}})})},function(t,e,n){"use strict";function a(t){return t&&t.__esModule?t:{default:t}}var i=n(0),r=a(i),o=n(1),s=a(o);r.default.entwine("ss",function(t){t(".cms-edit-form :input[name=ClassName]").entwine({onchange:function(){alert(s.default._t("CMS.ALERTCLASSNAME"))}}),t(".cms-edit-form input[name=Title]").entwine({onmatch:function(){var e=this;e.data("OrigVal",e.val());var n=e.closest("form"),a=t("input:text[name=URLSegment]",n),i=t("input[name=LiveLink]",n);a.length>0&&(e._addActions(),this.bind("change",function(n){var r=e.data("OrigVal"),o=e.val();e.data("OrigVal",o),0===a.val().indexOf(a.data("defaultUrl"))&&""==i.val()?e.updateURLSegment(o):t(".update",e.parent()).show(),e.updateRelatedFields(o,r),e.updateBreadcrumbLabel(o)})),this._super()},onunmatch:function(){this._super()},updateRelatedFields:function(e,n){this.parents("form").find("input[name=MetaTitle], input[name=MenuTitle]").each(function(){var a=t(this);a.val()==n&&(a.val(e),a.updatedRelatedFields&&a.updatedRelatedFields())})},updateURLSegment:function(e){var n=t("input:text[name=URLSegment]",this.closest("form")),a=n.closest(".field.urlsegment"),i=t(".update",this.parent());a.update(e),i.is(":visible")&&i.hide()},updateBreadcrumbLabel:function(e){var n=(t(".cms-edit-form input[name=ID]").val(),t("span.cms-panel-link.crumb"));e&&""!=e&&n.text(e)},_addActions:function(){var e,n=this;e=t("