diff --git a/CHANGELOG.md b/CHANGELOG.md index fda01a2fc66..2dc32abd365 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,14 @@ - Fixed a bug where disclosure menus weren’t releasing their `scroll` and `resize` event listeners on hide. ([#14911](https://github.com/craftcms/cms/pull/14911]), [#14510](https://github.com/craftcms/cms/issues/14510)) - Fixed a bug where it was possible to delete entries from Matrix fields which were configured to display nested entries statically. ([#14904](https://github.com/craftcms/cms/issues/14904), [#14915](https://github.com/craftcms/cms/pull/14915)) - Fixed an error that could occur when creating a nested entry in a Matrix field. ([#14915](https://github.com/craftcms/cms/pull/14915)) +- Fixed a bug where nested entry draft data could get corrupted when a draft was created for the owner element. +- Fixed a bug where Matrix and Addresses fields could show drafts of their nested elements when in card view. +- Fixed a bug where nested elements’ breadcrumbs could include the draft label, styled like it was part of the element’s title. - Fixed a bug where action buttons might not work for nested entries in Matrix fields set to card view. ([#14915](https://github.com/craftcms/cms/pull/14915)) - Fixed the styling of tag chips within Tags fields. ([#14916](https://github.com/craftcms/cms/issues/14916)) - Fixed a bug where field layout component settings slideouts’ footers had extra padding. +- Fixed a bug where MySQL backups weren’t restorable on certain environments. ([#14925](https://github.com/craftcms/cms/pull/14925)) +- Fixed a bug where `app/resource-js` requests weren’t working for guest requests. ([#14908](https://github.com/craftcms/cms/issues/14908)) ## 5.1.0 - 2024-04-30 diff --git a/src/base/Element.php b/src/base/Element.php index d7f947c971c..6c69608df7d 100644 --- a/src/base/Element.php +++ b/src/base/Element.php @@ -3132,7 +3132,11 @@ public function getCrumbs(): array if ($owner) { return [ ...$owner->getCrumbs(), - ['html' => Cp::elementChipHtml($owner)], + [ + 'html' => Cp::elementChipHtml($owner, [ + 'showDraftName' => false, + ]), + ], ]; } } diff --git a/src/controllers/AppController.php b/src/controllers/AppController.php index 2f2c6624903..3e325bd7d02 100644 --- a/src/controllers/AppController.php +++ b/src/controllers/AppController.php @@ -60,6 +60,7 @@ class AppController extends Controller 'migrate' => self::ALLOW_ANONYMOUS_LIVE | self::ALLOW_ANONYMOUS_OFFLINE, 'broken-image' => self::ALLOW_ANONYMOUS_LIVE | self::ALLOW_ANONYMOUS_OFFLINE, 'health-check' => self::ALLOW_ANONYMOUS_LIVE, + 'resource-js' => self::ALLOW_ANONYMOUS_LIVE | self::ALLOW_ANONYMOUS_OFFLINE, ]; /** diff --git a/src/db/mysql/Schema.php b/src/db/mysql/Schema.php index 1c8a6a8dfd3..3a7aba54a25 100644 --- a/src/db/mysql/Schema.php +++ b/src/db/mysql/Schema.php @@ -201,7 +201,7 @@ public function getDefaultBackupCommand(?array $ignoreTables = null): string $commandFromConfig = Craft::$app->getConfig()->getGeneral()->backupCommand; // https://bugs.mysql.com/bug.php?id=109685 - $useSingleTransaction = $isMySQL8 && version_compare($serverVersion, '8.0.32', '>='); + $useSingleTransaction = $isMySQL8 && version_compare($serverVersion, '8.0.32', '<'); if ($useSingleTransaction) { $baseCommand->addArg('--single-transaction'); diff --git a/src/elements/NestedElementManager.php b/src/elements/NestedElementManager.php index 0dfdfd9cb2f..8c80a263507 100644 --- a/src/elements/NestedElementManager.php +++ b/src/elements/NestedElementManager.php @@ -383,7 +383,7 @@ function(string $id, array $config, $attribute, &$settings) use ($owner) { ]); /** @var NestedElementInterface[] $elements */ - $elements = $this->getValue($owner, true)->all(); + $elements = $this->getValue($owner)->all(); $this->setOwnerOnNestedElements($owner, $elements); if (!empty($elements)) { @@ -695,14 +695,25 @@ private function saveNestedElements(ElementInterface $owner): void $element->setSortOrder($sortOrder); $elementsService->saveElement($element, false); - // If this is a draft, we can shed the draft data now - if ($element->getIsDraft()) { - $canonicalElementId = $element->getCanonicalId(); - Craft::$app->getDrafts()->removeDraftData($element); - Db::delete(Table::ELEMENTS_OWNERS, [ - 'elementId' => $canonicalElementId, - 'ownerId' => $owner->id, - ]); + // If this element's primary owner is $owner, and it’s a draft of another element whose owner is + // $owner's canonical (e.g. a draft entry created by Matrix::_createEntriesFromSerializedData()), + // we can shed its draft data and relation with the canonical owner now + if ( + $element->getPrimaryOwnerId() === $owner->id && + $element->getIsDraft() && + !$element->getIsUnpublishedDraft() && + $owner->getIsDraft() && + !$owner->getIsUnpublishedDraft() + ) { + /** @var NestedElementInterface $canonical */ + $canonical = $element->getCanonical(true); + if ($canonical->getPrimaryOwnerId() === $owner->getCanonicalId()) { + Craft::$app->getDrafts()->removeDraftData($element); + Db::delete(Table::ELEMENTS_OWNERS, [ + 'elementId' => $canonical->id, + 'ownerId' => $owner->id, + ]); + } } } elseif ((int)$element->getSortOrder() !== $sortOrder) { // Just update its sortOrder diff --git a/src/web/assets/cp/dist/cp.js b/src/web/assets/cp/dist/cp.js index 47ae5001fdd..c2246be99b7 100644 --- a/src/web/assets/cp/dist/cp.js +++ b/src/web/assets/cp/dist/cp.js @@ -1,3 +1,3 @@ /*! For license information please see cp.js.LICENSE.txt */ -(function(){var __webpack_modules__={463:function(){Craft.Accordion=Garnish.Base.extend({$trigger:null,targetSelector:null,_$target:null,init:function(t){var e=this;this.$trigger=$(t),this.$trigger.data("accordion")&&(console.warn("Double-instantiating an accordion trigger on an element"),this.$trigger.data("accordion").destroy()),this.$trigger.data("accordion",this),this.targetSelector=this.$trigger.attr("aria-controls")?"#".concat(this.$trigger.attr("aria-controls")):null,this.targetSelector&&(this._$target=$(this.targetSelector)),this.addListener(this.$trigger,"click","onTriggerClick"),this.addListener(this.$trigger,"keypress",(function(t){var n=t.keyCode;n!==Garnish.SPACE_KEY&&n!==Garnish.RETURN_KEY||(t.preventDefault(),e.onTriggerClick())}))},onTriggerClick:function(){"true"===this.$trigger.attr("aria-expanded")?this.hideTarget(this._$target):this.showTarget(this._$target)},showTarget:function(t){var e=this;if(t&&t.length){this.showTarget._currentHeight=t.height(),t.removeClass("hidden"),this.$trigger.removeClass("collapsed").addClass("expanded").attr("aria-expanded","true");for(var n=0;n=this.settings.maxItems)){var e=$(t).appendTo(this.$tbody),n=e.find(".delete");this.settings.sortable&&this.sorter.addItems(e),this.$deleteBtns=this.$deleteBtns.add(n),this.addListener(n,"click","handleDeleteBtnClick"),this.totalItems++,this.updateUI()}},reorderItems:function(){var t=this;if(this.settings.sortable){for(var e=[],n=0;n=this.settings.maxItems?$(this.settings.newItemBtnSelector).addClass("hidden"):$(this.settings.newItemBtnSelector).removeClass("hidden"))}},{defaults:{tableSelector:null,noItemsSelector:null,newItemBtnSelector:null,idAttribute:"data-id",nameAttribute:"data-name",sortable:!1,allowDeleteAll:!0,minItems:0,maxItems:null,reorderAction:null,deleteAction:null,reorderSuccessMessage:Craft.t("app","New order saved."),reorderFailMessage:Craft.t("app","Couldn’t save new order."),confirmDeleteMessage:Craft.t("app","Are you sure you want to delete “{name}”?"),deleteSuccessMessage:Craft.t("app","“{name}” deleted."),deleteFailMessage:Craft.t("app","Couldn’t delete “{name}”."),onReorderItems:$.noop,onDeleteItem:$.noop}})},6872:function(){Craft.AssetImageEditor=Garnish.Modal.extend({$body:null,$footer:null,$imageTools:null,$buttons:null,$cancelBtn:null,$replaceBtn:null,$saveBtn:null,$focalPointBtn:null,$editorContainer:null,$straighten:null,$croppingCanvas:null,$spinner:null,$constraintContainer:null,$constraintRadioInputs:null,$customConstraints:null,canvas:null,image:null,viewport:null,focalPoint:null,grid:null,croppingCanvas:null,clipper:null,croppingRectangle:null,cropperHandles:null,cropperGrid:null,croppingShade:null,imageStraightenAngle:0,viewportRotation:0,originalWidth:0,originalHeight:0,imageVerticeCoords:null,zoomRatio:1,animationInProgress:!1,currentView:"",assetId:null,cacheBust:null,draggingCropper:!1,scalingCropper:!1,draggingFocal:!1,previousMouseX:0,previousMouseY:0,shiftKeyHeld:!1,editorHeight:0,editorWidth:0,cropperState:!1,scaleFactor:1,flipData:{},focalPointState:!1,maxImageSize:null,lastLoadedDimensions:null,imageIsLoading:!1,mouseMoveEvent:null,croppingConstraint:!1,constraintOrientation:"landscape",showingCustomConstraint:!1,saving:!1,renderImage:null,renderCropper:null,_queue:null,init:function(t,e){var n=this;this._queue=new Craft.Queue,this.cacheBust=Date.now(),this.setSettings(e,Craft.AssetImageEditor.defaults),null===this.settings.allowDegreeFractions&&(this.settings.allowDegreeFractions=Craft.isImagick),Garnish.prefersReducedMotion()&&(this.settings.animationDuration=1),this.assetId=t,this.flipData={x:0,y:0},this.$container=$('').appendTo(Garnish.$bod),this.$body=$('
').appendTo(this.$container),this.$footer=$('