From 0d2660d703e732ed5b1730aeb9a51f06ab0ce22b Mon Sep 17 00:00:00 2001 From: preciousdaleramirez Date: Mon, 15 May 2023 15:52:16 +0800 Subject: [PATCH 01/20] Fixed a bug where hasUnlimitedStock sets to NULL if no value is passed. --- src/elements/Variant.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elements/Variant.php b/src/elements/Variant.php index 69214f36b5..a03cc3c676 100644 --- a/src/elements/Variant.php +++ b/src/elements/Variant.php @@ -224,7 +224,7 @@ class Variant extends Purchasable /** * @var bool $hasUnlimitedStock */ - public $hasUnlimitedStock; + public $hasUnlimitedStock = false; /** * @var int $minQty From 6a7b47f4600737df130e5f799108b811e3294f91 Mon Sep 17 00:00:00 2001 From: preciousdaleramirez Date: Thu, 18 May 2023 10:29:11 +0800 Subject: [PATCH 02/20] Added changelog description --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8534b3e0f..f677def9e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,14 @@ # Release Notes for Craft Commerce +## Unreleased + +### Fixed +- Fixed a bug where querying a product variant with unlimited stock returns incorrect records. ([craftcms/feed-me#636](https://github.com/craftcms/feed-me/issues/636)) + ## 3.4.20.1 - 2023-03-21 ### Fixed -- Fixed a PHP error that occurred when using a third party shipping method. ([#3093])(https://github.com/craftcms/commerce/issues/3093) +- Fixed a PHP error that occurred when using a third party shipping method. ([#3093](https://github.com/craftcms/commerce/issues/3093)) ## 3.4.20 - 2023-02-21 From 36536cb5ff161aff8c4c89a776aaeedccbf215b6 Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Tue, 30 May 2023 14:16:26 +0800 Subject: [PATCH 03/20] Cleanup --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 139846d057..e1c789ae02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ ## Unreleased -### Fixed - Fixed a bug where querying a product variant with unlimited stock returns incorrect records. ([craftcms/feed-me#636](https://github.com/craftcms/feed-me/issues/636)) ## 3.4.21 - 2023-05-03 From d8a0fab8d23d0e15a29dfcd5905bac731db03675 Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Tue, 30 May 2023 14:18:51 +0800 Subject: [PATCH 04/20] Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1c789ae02..d182828d13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Fixed a bug where querying a product variant with unlimited stock returns incorrect records. ([craftcms/feed-me#636](https://github.com/craftcms/feed-me/issues/636)) +- Fixed a bug where querying a Variant with unlimited stock returns incorrect records. ([#636](https://github.com/craftcms/feed-me/issues/636)) ## 3.4.21 - 2023-05-03 From dc764f8f664a722ff881ca54cb3b005faf18c1fb Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Wed, 31 May 2023 18:09:05 +0800 Subject: [PATCH 05/20] Finish 3.4.22 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d182828d13..e64f3e7f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Release Notes for Craft Commerce -## Unreleased +## 3.4.22 - 2023-05-31 -- Fixed a bug where querying a Variant with unlimited stock returns incorrect records. ([#636](https://github.com/craftcms/feed-me/issues/636)) +- Fixed a bug where querying for variants could yield unexpected results. ([#636](https://github.com/craftcms/feed-me/issues/636)) ## 3.4.21 - 2023-05-03 From 1013b30dd2fa650f500d957e82fa68ad9e989e73 Mon Sep 17 00:00:00 2001 From: Mat Mc <14130522+MatMc@users.noreply.github.com> Date: Fri, 2 Jun 2023 10:17:00 -0400 Subject: [PATCH 06/20] Fix version number in composer.json composer.json for v3.4.22 is incorrectly set as v3.4.21 resulting in Craft's plugin update page prompting to update even when the latest version is installed. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 804528a202..cae7180704 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ }, "extra": { "handle": "commerce", - "version": "3.4.21", + "version": "3.4.22", "name": "Craft Commerce", "description": "Create beautifully bespoke ecommerce experiences", "developer": "Pixel & Tonic", From fc08a7be4bd723fbdc37f1f248b87bfd8a172605 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Sat, 3 Jun 2023 09:17:52 +0100 Subject: [PATCH 07/20] Finish 3.4.22.1 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e64f3e7f72..38d4683613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft Commerce +## 3.4.22.1 - 2023-06-03 + +- Fixed a bug where the incorrect version number was being shown after updating. + ## 3.4.22 - 2023-05-31 - Fixed a bug where querying for variants could yield unexpected results. ([#636](https://github.com/craftcms/feed-me/issues/636)) diff --git a/composer.json b/composer.json index cae7180704..b0180cbcf9 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ }, "extra": { "handle": "commerce", - "version": "3.4.22", + "version": "3.4.22.1", "name": "Craft Commerce", "description": "Create beautifully bespoke ecommerce experiences", "developer": "Pixel & Tonic", From c7ffb9cdd0e0b0c8e2be093272b0e15ff57b2d95 Mon Sep 17 00:00:00 2001 From: tom Date: Thu, 7 Sep 2023 14:58:41 +1000 Subject: [PATCH 08/20] fix: qualify `Emails::_createEmailQuery` `orderBy` Add the table alias to the `orderBy` to avoid driver specific ambiguity in the generated SQL when joining against another table that _also_ has a `name` column. This is in line with `States::_createStatesQuery`, and should fix #3263. --- src/services/Emails.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/Emails.php b/src/services/Emails.php index b516ac2e03..9eac0a76cc 100644 --- a/src/services/Emails.php +++ b/src/services/Emails.php @@ -910,7 +910,7 @@ private function _createEmailQuery(): Query 'emails.plainTextTemplatePath', 'emails.uid', ]) - ->orderBy('name') + ->orderBy('emails.name') ->from([Table::EMAILS . ' emails']); // todo: remove schema version condition after next beakpoint From 68aa538d409e21961bd1acf469578cd98cd51411 Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Thu, 7 Sep 2023 13:13:29 +0800 Subject: [PATCH 09/20] Changelog item --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d4683613..988ed9f030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft Commerce +## Unreleased + +- Fixed a bug where emails were not being ordered by name correctly. ([#3263](https://github.com/craftcms/commerce/issues/3263)) + ## 3.4.22.1 - 2023-06-03 - Fixed a bug where the incorrect version number was being shown after updating. From 0e1b8142d35fcc4f661440d1d0ca87dacccc96ba Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Mon, 11 Sep 2023 16:27:03 -0700 Subject: [PATCH 10/20] Fixed an XSS vulnerability. --- CHANGELOG.md | 1 + src/elements/Product.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 988ed9f030..3c79a38f69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Fixed a bug where emails were not being ordered by name correctly. ([#3263](https://github.com/craftcms/commerce/issues/3263)) +- Fixed an XSS vulnerability. ## 3.4.22.1 - 2023-06-03 diff --git a/src/elements/Product.php b/src/elements/Product.php index c9fa869e6c..19c700fbc9 100644 --- a/src/elements/Product.php +++ b/src/elements/Product.php @@ -1303,7 +1303,7 @@ protected function tableAttributeHtml(string $attribute): string switch ($attribute) { case 'type': { - return ($productType ? Craft::t('site', $productType->name) : ''); + return ($productType ? Craft::t('site', Html::encode($productType->name)) : ''); } case 'defaultSku': { @@ -1313,13 +1313,13 @@ protected function tableAttributeHtml(string $attribute): string { $taxCategory = $this->getTaxCategory(); - return ($taxCategory ? Craft::t('site', $taxCategory->name) : ''); + return ($taxCategory ? Craft::t('site', Html::encode($taxCategory->name)) : ''); } case 'shippingCategory': { $shippingCategory = $this->getShippingCategory(); - return ($shippingCategory ? Craft::t('site', $shippingCategory->name) : ''); + return ($shippingCategory ? Craft::t('site', Html::encode($shippingCategory->name)) : ''); } case 'defaultPrice': { From ae504310dbea7f7e3f21405170f1e807e99ca699 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Mon, 9 Oct 2023 15:25:00 +0100 Subject: [PATCH 11/20] Updated `CustomerConditionRule` to use the element selector fixes #3291 --- CHANGELOG.md | 1 + .../orders/CustomerConditionRule.php | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abf3785a0..7ad6b4da22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Added the `commerce/gateways/webhook-url` command. - Fixed a bug where the delete button would be shown for users that do not have permission to delete on the Product edit page. ([#3285](https://github.com/craftcms/commerce/issues/3285)) - Fixed a bug where deleted shipping categories were still available for selection. ([#3272](https://github.com/craftcms/commerce/issues/3272)) +- Fixed a bug where the customer condition rule wasn’t loading correctly. ([#3291](https://github.com/craftcms/commerce/issues/3291)) ## 4.3.0 - 2023-09-13 diff --git a/src/elements/conditions/orders/CustomerConditionRule.php b/src/elements/conditions/orders/CustomerConditionRule.php index 02aa7d9ac4..1c4e666f5c 100644 --- a/src/elements/conditions/orders/CustomerConditionRule.php +++ b/src/elements/conditions/orders/CustomerConditionRule.php @@ -15,6 +15,8 @@ use craft\elements\conditions\ElementConditionRuleInterface; use craft\elements\db\ElementQueryInterface; use craft\elements\User; +use craft\helpers\ArrayHelper; +use craft\helpers\Cp; use yii\base\InvalidConfigException; /** @@ -22,6 +24,7 @@ * * @author Pixel & Tonic, Inc. * @since 4.2.0 + * @TODO change the class that the `CustomerConditionRule` extends */ class CustomerConditionRule extends BaseMultiSelectConditionRule implements ElementConditionRuleInterface { @@ -35,6 +38,7 @@ public function getLabel(): string /** * @return array + * @deprecated in 4.3.1. */ protected function options(): array { @@ -47,6 +51,24 @@ protected function options(): array ->all(); } + /** + * @inheritDoc + */ + protected function inputHtml(): string + { + $users = User::find()->status(null)->limit(null)->id($this->values)->all(); + + return Cp::elementSelectHtml([ + 'name' => 'values', + 'elements' => $users, + 'elementType' => User::class, + 'sources' => null, + 'criteria' => null, + 'condition' => null, + 'single' => false, + ]); + } + /** * @inheritdoc */ @@ -63,7 +85,7 @@ public function modifyQuery(ElementQueryInterface $query): void /** @var OrderQuery $query */ $paramValue = $this->paramValue(); if ($this->operator === self::OPERATOR_NOT_IN) { - $paramValue = ['or', $paramValue, null]; + ArrayHelper::prependOrAppend($paramValue, 'not', true); } $query->customerId($paramValue); From 4d3b83670f95a5a172a9c502a919e7b0e454a94f Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Tue, 10 Oct 2023 15:21:23 +0100 Subject: [PATCH 12/20] Fix not in query for customer condition rule --- .../conditions/orders/CustomerConditionRule.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/elements/conditions/orders/CustomerConditionRule.php b/src/elements/conditions/orders/CustomerConditionRule.php index 1c4e666f5c..00248bfc69 100644 --- a/src/elements/conditions/orders/CustomerConditionRule.php +++ b/src/elements/conditions/orders/CustomerConditionRule.php @@ -15,9 +15,10 @@ use craft\elements\conditions\ElementConditionRuleInterface; use craft\elements\db\ElementQueryInterface; use craft\elements\User; -use craft\helpers\ArrayHelper; use craft\helpers\Cp; +use craft\helpers\Db; use yii\base\InvalidConfigException; +use yii\db\Expression; /** * Customer Condition Rule @@ -85,10 +86,11 @@ public function modifyQuery(ElementQueryInterface $query): void /** @var OrderQuery $query */ $paramValue = $this->paramValue(); if ($this->operator === self::OPERATOR_NOT_IN) { - ArrayHelper::prependOrAppend($paramValue, 'not', true); + // Account for the fact the querying using a combination of `not` and `in` doesn't match `null` in the column + $query->andWhere(Db::parseParam(new Expression('coalesce([[commerce_orders.customerId]], -1)'), $paramValue)); + } else { + $query->customerId($paramValue); } - - $query->customerId($paramValue); } /** From eabb67536e3448bc2ec3a38520a6752bee9504d5 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 13 Oct 2023 14:15:47 +0100 Subject: [PATCH 13/20] Update address add button --- example-templates/dist/shop/_private/address/list.twig | 8 +++++--- example-templates/src/shop/_private/address/list.twig | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/example-templates/dist/shop/_private/address/list.twig b/example-templates/dist/shop/_private/address/list.twig index 1e5592eb2d..9f451f3e6a 100644 --- a/example-templates/dist/shop/_private/address/list.twig +++ b/example-templates/dist/shop/_private/address/list.twig @@ -52,9 +52,11 @@ {% endfor %} {% if showAdd %} - -
- Add Address + +
+
+ Add Address +
{% endif %} diff --git a/example-templates/src/shop/_private/address/list.twig b/example-templates/src/shop/_private/address/list.twig index b27cf1a6ba..0c97f062a8 100644 --- a/example-templates/src/shop/_private/address/list.twig +++ b/example-templates/src/shop/_private/address/list.twig @@ -52,9 +52,11 @@
{% endfor %} {% if showAdd %} - -
- Add Address + +
+
+ Add Address +
{% endif %} From 584456f7141d9a6f70327244f3e885bea460cf65 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 13 Oct 2023 14:24:50 +0100 Subject: [PATCH 14/20] Primary emojis on address list in example templates --- .../dist/shop/_private/address/list.twig | 12 +++++++++++- .../src/shop/_private/address/list.twig | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/example-templates/dist/shop/_private/address/list.twig b/example-templates/dist/shop/_private/address/list.twig index 9f451f3e6a..2386f7dff5 100644 --- a/example-templates/dist/shop/_private/address/list.twig +++ b/example-templates/dist/shop/_private/address/list.twig @@ -10,7 +10,7 @@
{% for address in addresses %} {% set editUrl = '/shop/customer/addresses/edit?addressId=' ~ address.id ~ '&redirect=' ~ craft.app.request.fullPath %} -
+
{% tag selectable ? 'label' : 'div' with { class: 'block relative address-select js-address-select', data: { @@ -49,6 +49,16 @@ {% endif %} {% endtag %} + {% if primaryBillingAddressId == address.id or primaryShippingAddressId == address.id %} +
+ {% if primaryBillingAddressId == address.id %} + 💳 + {% endif %} + {% if primaryShippingAddressId == address.id %} + 📦 + {% endif %} +
+ {% endif %}
{% endfor %} {% if showAdd %} diff --git a/example-templates/src/shop/_private/address/list.twig b/example-templates/src/shop/_private/address/list.twig index 0c97f062a8..d653691ea6 100644 --- a/example-templates/src/shop/_private/address/list.twig +++ b/example-templates/src/shop/_private/address/list.twig @@ -10,7 +10,7 @@
{% for address in addresses %} {% set editUrl = '/[[folderName]]/customer/addresses/edit?addressId=' ~ address.id ~ '&redirect=' ~ craft.app.request.fullPath %} -
+
{% tag selectable ? 'label' : 'div' with { class: 'block relative address-select js-address-select', data: { @@ -49,6 +49,16 @@ {% endif %} {% endtag %} + {% if primaryBillingAddressId == address.id or primaryShippingAddressId == address.id %} +
+ {% if primaryBillingAddressId == address.id %} + 💳 + {% endif %} + {% if primaryShippingAddressId == address.id %} + 📦 + {% endif %} +
+ {% endif %}
{% endfor %} {% if showAdd %} From 8ff5dd51a33fa19d109fb333c73dc95006197483 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 13 Oct 2023 14:25:18 +0100 Subject: [PATCH 15/20] Remove JS noise from address primary settings --- .../dist/shop/_private/address/fields.twig | 20 ++++-------------- .../src/shop/_private/address/fields.twig | 21 ++++--------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/example-templates/dist/shop/_private/address/fields.twig b/example-templates/dist/shop/_private/address/fields.twig index 77bfb0a8db..e0fa3299c4 100644 --- a/example-templates/dist/shop/_private/address/fields.twig +++ b/example-templates/dist/shop/_private/address/fields.twig @@ -198,29 +198,17 @@ Outputs address form fields for editing an address. {% if showPrimaryCheckboxes %}
- {{ input('hidden', 'isPrimaryBilling', address.isPrimarybilling ? 1 : 0) }} - + {{ hiddenInput('isPrimaryBilling', 0) }} +
- {{ input('hidden', 'isPrimaryShipping', address.isPrimaryShipping ? 1 : 0) }} - + {{ hiddenInput('isPrimaryShipping', 0) }} +
{% endif %}
{% js %} -{% if showPrimaryCheckboxes %} -document.querySelectorAll('input[type=checkbox][data-primary-input]').forEach(el => { - el.addEventListener('change', ev => { - let primaryInput = document.querySelector(`input[name="${ev.target.dataset.primaryInput}"]`); - if (ev.target.checked) { - primaryInput.value = 1; - } else { - primaryInput.value = 0; - } - }); -}); -{% endif %} document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').addEventListener('change', ev => { const countryCode = ev.target.value; diff --git a/example-templates/src/shop/_private/address/fields.twig b/example-templates/src/shop/_private/address/fields.twig index 6fa6ebf00b..2af88ecfa4 100755 --- a/example-templates/src/shop/_private/address/fields.twig +++ b/example-templates/src/shop/_private/address/fields.twig @@ -198,30 +198,17 @@ Outputs address form fields for editing an address. {% if showPrimaryCheckboxes %}
- {{ input('hidden', 'isPrimaryBilling', address.isPrimarybilling ? 1 : 0) }} - + {{ hiddenInput('isPrimaryBilling', 0) }} +
- {{ input('hidden', 'isPrimaryShipping', address.isPrimaryShipping ? 1 : 0) }} - + {{ hiddenInput('isPrimaryShipping', 0) }} +
{% endif %}
{% js %} -{% if showPrimaryCheckboxes %} -document.querySelectorAll('input[type=checkbox][data-primary-input]').forEach(el => { - el.addEventListener('change', ev => { - let primaryInput = document.querySelector(`input[name="${ev.target.dataset.primaryInput}"]`); - if (ev.target.checked) { - primaryInput.value = 1; - } else { - primaryInput.value = 0; - } - }); -}); -{% endif %} - document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').addEventListener('change', ev => { const countryCode = ev.target.value; const stateSelect = document.querySelector('select#{{ 'administrativeArea'|namespaceInputId(addressName) }}'); From e0ed13c67861457c22013de8e57138de93afb65e Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 13 Oct 2023 14:27:25 +0100 Subject: [PATCH 16/20] whitespace --- example-templates/dist/shop/_private/address/fields.twig | 1 - 1 file changed, 1 deletion(-) diff --git a/example-templates/dist/shop/_private/address/fields.twig b/example-templates/dist/shop/_private/address/fields.twig index e0fa3299c4..185436c4cd 100644 --- a/example-templates/dist/shop/_private/address/fields.twig +++ b/example-templates/dist/shop/_private/address/fields.twig @@ -209,7 +209,6 @@ Outputs address form fields for editing an address.
{% js %} - document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').addEventListener('change', ev => { const countryCode = ev.target.value; const stateSelect = document.querySelector('select#{{ 'administrativeArea'|namespaceInputId(addressName) }}'); From 8b8920ae824f40d8441b1282d966a286709d2d8f Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 13 Oct 2023 15:46:19 +0100 Subject: [PATCH 17/20] Fixed #3299 malformed webhook URL --- CHANGELOG.md | 3 ++- src/base/Gateway.php | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c79a38f69..5f04b1e806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,9 @@ ## Unreleased -- Fixed a bug where emails were not being ordered by name correctly. ([#3263](https://github.com/craftcms/commerce/issues/3263)) - Fixed an XSS vulnerability. +- Fixed a bug where emails were not being ordered by name correctly. ([#3263](https://github.com/craftcms/commerce/issues/3263)) +- Fixed a bug where a gateway’s webhook URL was malformed. ([#3299](https://github.com/craftcms/commerce/issues/3299)) ## 3.4.22.1 - 2023-06-03 diff --git a/src/base/Gateway.php b/src/base/Gateway.php index 7c8d6a03d0..1e778fa918 100644 --- a/src/base/Gateway.php +++ b/src/base/Gateway.php @@ -54,7 +54,12 @@ public function getWebhookUrl(array $params = []): string $url = UrlHelper::actionUrl('commerce/webhooks/process-webhook', $params); - return StringHelper::replace($url, Craft::$app->getConfig()->getGeneral()->cpTrigger . '/', ''); + // Remove the cpTrigger from the url if it's there. + if (Craft::$app->getConfig()->getGeneral()->cpTrigger) { + $url = StringHelper::replace($url, Craft::$app->getConfig()->getGeneral()->cpTrigger . '/', ''); + } + + return $url; } /** From fb9d51bf9bac5d26033b56215f14dc33f35e8f14 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 13 Oct 2023 20:30:33 +0100 Subject: [PATCH 18/20] #3286 prevent duplicate inactive users being created during upgrade --- CHANGELOG.md | 1 + src/console/controllers/UpgradeController.php | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 276e6ac29a..21e7c8f5b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Fixed a bug where the delete button would be shown for users that do not have permission to delete on the Product edit page. ([#3285](https://github.com/craftcms/commerce/issues/3285)) - Fixed a bug where deleted shipping categories were still available for selection. ([#3272](https://github.com/craftcms/commerce/issues/3272)) - Fixed an error that could occur when rendering a PDF. ([#2633](https://github.com/craftcms/commerce/issues/2633)) +- Fixed a bug where duplicate inactive users could be created when using the `commerce/upgrade` command. ([#3286](https://github.com/craftcms/commerce/issues/3286)) ## 4.3.0 - 2023-09-13 diff --git a/src/console/controllers/UpgradeController.php b/src/console/controllers/UpgradeController.php index 8b6b50dff3..ff274714cc 100644 --- a/src/console/controllers/UpgradeController.php +++ b/src/console/controllers/UpgradeController.php @@ -1179,6 +1179,7 @@ public function _migrateCustomers(): void ->leftJoin(['u' => $usersTable], 'o.email = u.email') ->where(['u.email' => null]) ->andWhere(['not', ['o.email' => null]]) + ->groupBy(['[[o.email]]']) ->column(); $this->stdoutlast(' Done. Found ' . count($guestEmails) . ' guest emails.', Console::FG_GREEN); From d4d4dc79d0fc8884b158a2a867a5e458e273aebc Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Mon, 16 Oct 2023 13:35:38 +0100 Subject: [PATCH 19/20] Fixed #3302 anonymous guest carts being linked to single user --- src/console/controllers/UpgradeController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/console/controllers/UpgradeController.php b/src/console/controllers/UpgradeController.php index ff274714cc..f9b9d20348 100644 --- a/src/console/controllers/UpgradeController.php +++ b/src/console/controllers/UpgradeController.php @@ -1181,6 +1181,7 @@ public function _migrateCustomers(): void ->andWhere(['not', ['o.email' => null]]) ->groupBy(['[[o.email]]']) ->column(); + $guestEmails = array_filter($guestEmails); $this->stdoutlast(' Done. Found ' . count($guestEmails) . ' guest emails.', Console::FG_GREEN); // We know we have to make a user for every guest email address From cff0b7b3bcff79eebcce91834cc188ee9603e0b2 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Tue, 17 Oct 2023 09:14:53 +0100 Subject: [PATCH 20/20] Move to more performant query instead of `array_filter` #3286 --- src/console/controllers/UpgradeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console/controllers/UpgradeController.php b/src/console/controllers/UpgradeController.php index f9b9d20348..a580fa2652 100644 --- a/src/console/controllers/UpgradeController.php +++ b/src/console/controllers/UpgradeController.php @@ -1179,9 +1179,9 @@ public function _migrateCustomers(): void ->leftJoin(['u' => $usersTable], 'o.email = u.email') ->where(['u.email' => null]) ->andWhere(['not', ['o.email' => null]]) + ->andWhere(['not', ['o.email' => '']]) ->groupBy(['[[o.email]]']) ->column(); - $guestEmails = array_filter($guestEmails); $this->stdoutlast(' Done. Found ' . count($guestEmails) . ' guest emails.', Console::FG_GREEN); // We know we have to make a user for every guest email address