From fe514c6529954f2ccbb4ceba229ace6915dd40a6 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Fri, 9 Feb 2024 07:54:38 +0000 Subject: [PATCH 01/22] report newLocation error in asset slideout --- src/elements/Asset.php | 3 +++ src/helpers/Cp.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/elements/Asset.php b/src/elements/Asset.php index 6aac6001e35..3435fdca5c7 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -2674,6 +2674,9 @@ protected function metaFieldsHtml(bool $static): string 'required' => true, 'class' => ['text', 'filename'], 'disabled' => $static, + 'data' => [ + 'attribute' => 'newLocation', + ], ]), parent::metaFieldsHtml($static), ]); diff --git a/src/helpers/Cp.php b/src/helpers/Cp.php index 4d2a0ab60c7..8800143fab0 100644 --- a/src/helpers/Cp.php +++ b/src/helpers/Cp.php @@ -777,7 +777,7 @@ public static function fieldHtml(string $input, array $config = []): string 'class' => $fieldClass, 'id' => $fieldId, 'data' => [ - 'attribute' => $attribute, + 'attribute' => $config['data']['attribute'] ?? $attribute, ], ], $config['fieldAttributes'] ?? [] From 066857df5a2d5f426f45b93384db05ccb23a2077 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 9 Feb 2024 20:07:29 -0800 Subject: [PATCH 02/22] Fixed #14324 --- CHANGELOG.md | 4 ++++ src/web/Application.php | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff489ae15bd..213729b025d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft CMS 4 +## Unreleased + +- Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324)) + ## 4.7.2.1 - 2024-02-08 - Craft now requires Composer ^2.7.0. ([CVE-2024-24821](https://github.com/advisories/GHSA-7c6p-848j-wh5h)) diff --git a/src/web/Application.php b/src/web/Application.php index 3fa72bf9169..8dae1f2ff4a 100644 --- a/src/web/Application.php +++ b/src/web/Application.php @@ -161,7 +161,7 @@ public function handleRequest($request, bool $skipSpecialHandling = false): Resp // Process resource requests before anything else $this->_processResourceRequest($request); - // Disable read/write splitting for POST requests + // Disable read/write splitting for most POST requests if ( $request->getIsPost() && !in_array($request->getActionSegments(), [ @@ -171,7 +171,9 @@ public function handleRequest($request, bool $skipSpecialHandling = false): Resp ['element-indexes', 'get-elements'], ['element-indexes', 'get-more-elements'], ['element-indexes', 'get-source-tree-html'], - ]) + ['graphql', 'api'], + ]) && + !$request->getIsGraphql() ) { $this->getDb()->enableReplicas = false; } From d86bd90e58db325bf24dc3d20bd6f426f097020f Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Sat, 10 Feb 2024 13:58:30 -0800 Subject: [PATCH 03/22] ;-| [ci skip] --- src/elements/Asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elements/Asset.php b/src/elements/Asset.php index 6aac6001e35..72d5476f8a2 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -2540,7 +2540,7 @@ public function getPreviewHtml(): string Html::tag('div', $this->getPreviewThumbImg(350, 190), [ 'class' => 'preview-thumb', ]) . - Html::endTag('div'); // .preview-thumb-container; + Html::endTag('div'); // .preview-thumb-container if ($previewable || $editable) { $isMobile = Craft::$app->getRequest()->isMobileBrowser(true); From 5e14cef6346752d7d80a33068d1305050ee7e847 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Mon, 12 Feb 2024 08:35:56 +0000 Subject: [PATCH 04/22] different approach --- src/elements/Asset.php | 4 +--- src/helpers/Cp.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/elements/Asset.php b/src/elements/Asset.php index 3435fdca5c7..4bed2f5f070 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -2666,6 +2666,7 @@ protected function metaFieldsHtml(bool $static): string return implode("\n", [ Cp::textFieldHtml([ 'label' => Craft::t('app', 'Filename'), + 'attribute' => 'newLocation', 'id' => 'new-filename', 'name' => 'newFilename', 'value' => $this->_filename, @@ -2674,9 +2675,6 @@ protected function metaFieldsHtml(bool $static): string 'required' => true, 'class' => ['text', 'filename'], 'disabled' => $static, - 'data' => [ - 'attribute' => 'newLocation', - ], ]), parent::metaFieldsHtml($static), ]); diff --git a/src/helpers/Cp.php b/src/helpers/Cp.php index 8800143fab0..4d2a0ab60c7 100644 --- a/src/helpers/Cp.php +++ b/src/helpers/Cp.php @@ -777,7 +777,7 @@ public static function fieldHtml(string $input, array $config = []): string 'class' => $fieldClass, 'id' => $fieldId, 'data' => [ - 'attribute' => $config['data']['attribute'] ?? $attribute, + 'attribute' => $attribute, ], ], $config['fieldAttributes'] ?? [] From 783c601b0ad306894cf538354b34e33b31b20f95 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Mon, 12 Feb 2024 04:01:34 -0800 Subject: [PATCH 05/22] Don't show empty headings on the GQL schema edit page [ci skip] --- CHANGELOG.md | 1 + src/templates/graphql/schemas/_edit.twig | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 213729b025d..a97dc84d8fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324)) +- Fixed a bug where GraphQL schema edit pages could include empty category headings. ## 4.7.2.1 - 2024-02-08 diff --git a/src/templates/graphql/schemas/_edit.twig b/src/templates/graphql/schemas/_edit.twig index 46a64675d1e..64c6bdd3570 100644 --- a/src/templates/graphql/schemas/_edit.twig +++ b/src/templates/graphql/schemas/_edit.twig @@ -85,7 +85,7 @@ {% set schemaComponents = craft.app.gql.getAllSchemaComponents %} - {% for category, catPermissions in schemaComponents.queries %} + {% for category, catPermissions in schemaComponents.queries|filter %}

{{ category }}

@@ -97,7 +97,7 @@

{{ 'Choose the available mutations for this schema:'|t('app') }}

- {% for category, catPermissions in schemaComponents.mutations %} + {% for category, catPermissions in schemaComponents.mutations|filter %}

{{ category }}

From c2ff8bb6547ae7d27826e415d637df8a8fb4a294 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Mon, 12 Feb 2024 13:43:20 +0000 Subject: [PATCH 06/22] delete relations if the element was deleted for a site --- src/fields/BaseRelationField.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/fields/BaseRelationField.php b/src/fields/BaseRelationField.php index ac0092780b8..221e6f17006 100644 --- a/src/fields/BaseRelationField.php +++ b/src/fields/BaseRelationField.php @@ -1013,6 +1013,22 @@ public function afterElementSave(ElementInterface $element, bool $isNew): void parent::afterElementSave($element, $isNew); } + /** + * @inheritdoc + */ + public function afterElementDeleteForSite(ElementInterface $element): void + { + if ($this->localizeRelations) { + Db::delete(DbTable::RELATIONS, [ + 'fieldId' => $this->id, + 'sourceSiteId' => $element->siteId, + 'sourceId' => $element->id, + ]); + } + + parent::afterElementDeleteForSite($element); + } + /** * Normalizes the available sources into select input options. * From 6d465d08aa6ec3bcfc19ccfee00c7887bcc476ff Mon Sep 17 00:00:00 2001 From: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Mon, 12 Feb 2024 09:32:01 -0600 Subject: [PATCH 07/22] Remove non-existent `$path` @property --- src/web/Request.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/web/Request.php b/src/web/Request.php index 7ecf672b05b..08b28dfc532 100644 --- a/src/web/Request.php +++ b/src/web/Request.php @@ -30,7 +30,6 @@ /** * @inheritdoc * @property string $fullPath The full requested path, including the control panel trigger and pagination info. - * @property string $path The requested path, sans control panel trigger and pagination info. * @property array $segments The segments of the requested path. * @property int $pageNum The requested page number. * @property string $token The token submitted with the request, if there is one. From 290ce6038321b7f7c0365e0252e88f3dce80b3b0 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Tue, 13 Feb 2024 13:37:27 +0000 Subject: [PATCH 08/22] number decimals validation rule for mysql --- src/fields/Number.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/fields/Number.php b/src/fields/Number.php index 3b5e9829434..935db65d476 100644 --- a/src/fields/Number.php +++ b/src/fields/Number.php @@ -130,6 +130,15 @@ protected function defineRules(): array $rules = parent::defineRules(); $rules[] = [['defaultValue', 'min', 'max'], 'number']; $rules[] = [['decimals', 'size'], 'integer']; + + if ( + $this->decimals && + Craft::$app->getDb()->getIsMysql() && + version_compare(Craft::$app->getInfo()->version, '5.0', '<') + ) { + $rules[] = [['decimals'], 'integer', 'max' => 30]; + } + $rules[] = [ ['max'], 'compare', From 99ba1f10006808758940990917e9f54cbf6142da Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 13 Feb 2024 11:14:15 -0800 Subject: [PATCH 09/22] Release note [ci skip] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a97dc84d8fd..42cfde39db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324)) - Fixed a bug where GraphQL schema edit pages could include empty category headings. +- Fixed a bug where asset slideouts weren’t showing validation errors on the Filename field. ([#14329](https://github.com/craftcms/cms/issues/14329)) ## 4.7.2.1 - 2024-02-08 From bbb43b895914f8f9f0eee6fee5f4d9d6310b3c22 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 13 Feb 2024 14:38:35 -0800 Subject: [PATCH 10/22] Adapt #14357 for element select inputs [ci skip] --- CHANGELOG.md | 1 + src/web/assets/cp/dist/cp.js | 2 +- src/web/assets/cp/dist/cp.js.map | 2 +- src/web/assets/cp/src/js/BaseElementSelectInput.js | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42cfde39db1..d6792c47df5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324)) - Fixed a bug where GraphQL schema edit pages could include empty category headings. - Fixed a bug where asset slideouts weren’t showing validation errors on the Filename field. ([#14329](https://github.com/craftcms/cms/issues/14329)) +- Fixed a bug where element slideouts would open when long-pressing on an element’s “Remove” button within an element select input. ## 4.7.2.1 - 2024-02-08 diff --git a/src/web/assets/cp/dist/cp.js b/src/web/assets/cp/dist/cp.js index 7eceab91e12..e98eec41c76 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 i=t.keyCode;i!==Garnish.SPACE_KEY&&i!==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 i=0;i .address-card");for(var s=0;s=this.settings.maxItems)){var e=$(t).appendTo(this.$tbody),i=e.find(".delete");this.settings.sortable&&this.sorter.addItems(e),this.$deleteBtns=this.$deleteBtns.add(i),this.addListener(i,"click","handleDeleteBtnClick"),this.totalItems++,this.updateUI()}},reorderItems:function(){var t=this;if(this.settings.sortable){for(var e=[],i=0;i=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 i=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=$('