Skip to content

Commit ad0ad0b

Browse files
committed
Merge branch 'release/4.4.1'
2 parents 27ca37d + dc06176 commit ad0ad0b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes for Craft Commerce
22

3+
## 4.4.1 - 2024-01-12
4+
5+
- Fixed a SQL error that could occur when updating to Commerce 4.4.0 on MySQL. ([#3367](https://github.com/craftcms/commerce/issues/3367))
6+
- Fixed a PHP error that occurred when saving a discount. ([#3364](https://github.com/craftcms/commerce/issues/3364))
7+
38
## 4.4.0 - 2024-01-11
49

510
- Craft Commerce now requires Craft CMS 4.6.0 or later.

src/controllers/DiscountsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function actionSave(): ?Response
239239
$discount->perEmailLimit = (int)$this->request->getBodyParam('perEmailLimit');
240240
$discount->totalDiscountUseLimit = (int)$this->request->getBodyParam('totalDiscountUseLimit');
241241
$discount->ignoreSales = (bool)$this->request->getBodyParam('ignoreSales');
242-
$discount->categoryRelationshipType = $this->request->getBodyParam('categoryRelationshipType');
242+
$discount->categoryRelationshipType = $this->request->getBodyParam('categoryRelationshipType', $discount->categoryRelationshipType);
243243
$discount->baseDiscountType = $this->request->getBodyParam('baseDiscountType') ?: DiscountRecord::BASE_DISCOUNT_TYPE_VALUE;
244244
$discount->appliedTo = $this->request->getBodyParam('appliedTo') ?: DiscountRecord::APPLIED_TO_MATCHING_LINE_ITEMS;
245245
$discount->orderConditionFormula = $this->request->getBodyParam('orderConditionFormula');

src/services/Discounts.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,12 @@ public function ensureSortOrder(): void
879879
} else {
880880
$sql = <<<SQL
881881
UPDATE $table a
882-
JOIN (SELECT id, [[sortOrder]], ROW_NUMBER() OVER (ORDER BY [[sortOrder]] ASC, id ASC) as rownumber
883-
FROM $table) b ON a.id = b.id
882+
JOIN (
883+
SELECT id, [[sortOrder]], (@ROW_NUMBER := @ROW_NUMBER + 1) as rownumber
884+
FROM $table,
885+
(SELECT @ROW_NUMBER := 0) AS X
886+
ORDER BY [[sortOrder]] ASC, id ASC
887+
) b ON a.id = b.id
884888
SET [[a.sortOrder]] = b.rownumber
885889
SQL;
886890
}

0 commit comments

Comments
 (0)