Skip to content

Commit 346c87d

Browse files
authored
Merge pull request #4014 from craftcms/4.9
4.9
2 parents ca86714 + 73ffd30 commit 346c87d

File tree

79 files changed

+829
-736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+829
-736
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: craftcms/.github/.github/workflows/ci.yml@v3
1717
with:
1818
craft_version: '4'
19-
jobs: '["ecs", "phpstan", "prettier", "tests"]'
19+
jobs: '["ecs", "phpstan", "prettier", "tests", "rector"]'
2020
notify_slack: true
2121
slack_subteam: <!subteam^S01CWPYH9D5>
2222
secrets:

CHANGELOG-WIP.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# WIP Release Note for Craft Commerce 4.9
2+
3+
- Added the `localized` field to products’ GraphQL data. ([#3783](https://github.com/craftcms/commerce/discussions/3783))
4+
- Added `craft\commerce\taxidvalidators\EuVatIdValidator::API_URL`.
5+
- Fixed a PHP error that could occur when saving an order. ([#3283](https://github.com/craftcms/commerce/issues/3283))

CHANGELOG.md

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

3-
## Unreleased
4-
5-
- Fixed a PHP error that could occur when saving an Order. ([#3283](https://github.com/craftcms/commerce/issues/3283))
6-
73
## 4.8.4 - 2025-05-01
84

95
- Fixed a bug where products weren’t getting updated when default variants were saved directly. ([#3988](https://github.com/craftcms/commerce/issues/3988))

composer.lock

Lines changed: 298 additions & 200 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rector.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<?php
2-
// rector.php
3-
use Rector\Set\ValueObject\SetList;
4-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
52

6-
return static function(ContainerConfigurator $containerConfigurator): void {
7-
// $containerConfigurator->import(SetList::CODE_QUALITY);
3+
declare(strict_types=1);
84

9-
// register single rule
10-
$services = $containerConfigurator->services();
11-
// $containerConfigurator->import(SetList::PHP_80);
12-
$services->set(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
13-
$services->set(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
14-
$services->set(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
15-
$services->set(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
16-
$services->set(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
17-
};
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/src',
10+
__DIR__ . '/tests/unit',
11+
])
12+
->withSkip([
13+
Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class => [
14+
__DIR__ . '/src/console/controllers/GatewaysController.php',
15+
],
16+
Rector\Php80\Rector\Class_\StringableForToStringRector::class,
17+
])
18+
->withPhpSets(php80: true);

src/base/Stat.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,7 @@ public function getOrderStatuses(): ?array
428428
continue;
429429
}
430430

431-
$orderStatus = ArrayHelper::firstWhere($allOrderStatuses, function(OrderStatus $os) use ($orderStatus) {
432-
return $orderStatus === $os->handle || $orderStatus === $os->uid;
433-
});
431+
$orderStatus = ArrayHelper::firstWhere($allOrderStatuses, fn(OrderStatus $os) => $orderStatus === $os->handle || $orderStatus === $os->uid);
434432
if (!$orderStatus) {
435433
unset($this->_orderStatuses[$key]);
436434
continue;

src/base/Zone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ abstract class Zone extends BaseModel implements ZoneInterface
4747
/**
4848
* @var ?ZoneAddressCondition
4949
*/
50-
private ?ZoneAddressCondition $_condition;
50+
private ?ZoneAddressCondition $_condition = null;
5151

5252
abstract public function getCpEditUrl(): string;
5353

src/console/controllers/UpgradeController.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,12 @@ public function actionRun(): int
263263
->all();
264264

265265
// Filter out the address columns we don't need to migrate to custom fields
266-
$this->neededCustomAddressFields = array_filter($this->neededCustomAddressFields, static function($fieldHandle) {
267-
return (new Query())
268-
->select($fieldHandle)
269-
->where(['not', [$fieldHandle => null]])
270-
->andWhere(['not', [$fieldHandle => '']])
271-
->from(['{{%commerce_addresses}}'])
272-
->exists();
273-
}, ARRAY_FILTER_USE_KEY);
266+
$this->neededCustomAddressFields = array_filter($this->neededCustomAddressFields, static fn($fieldHandle) => (new Query())
267+
->select($fieldHandle)
268+
->where(['not', [$fieldHandle => null]])
269+
->andWhere(['not', [$fieldHandle => '']])
270+
->from(['{{%commerce_addresses}}'])
271+
->exists(), ARRAY_FILTER_USE_KEY);
274272

275273
$startTime = DateTimeHelper::currentUTCDateTime();
276274

@@ -395,7 +393,7 @@ private function _migrateAddressCustomFields(): void
395393
$firstTab = $this->_addressFieldLayout->getTabs()[0];
396394
$layoutElements = $firstTab->getElements();
397395

398-
$list = implode(array_map(fn($label) => " - $label\n", $this->neededCustomAddressFields));
396+
$list = implode('', array_map(fn($label) => " - $label\n", $this->neededCustomAddressFields));
399397
$this->stdout(<<<EOL
400398
Customer and order addresses will be migrated to native Craft address elements.
401399
Some of the existing addresses contain data that will need to be stored in custom fields:

src/controllers/DiscountsController.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
use yii\web\HttpException;
3939
use yii\web\Response;
4040
use function explode;
41-
use function get_class;
4241

4342
/**
4443
* Class Discounts Controller
@@ -459,17 +458,11 @@ public function actionClearDiscountUses(): Response
459458
return $this->asFailure(Craft::t('commerce', 'Type not in allowed options.'));
460459
}
461460

462-
switch ($type) {
463-
case self::DISCOUNT_COUNTER_TYPE_EMAIL:
464-
Plugin::getInstance()->getDiscounts()->clearEmailUsageHistoryById($id);
465-
break;
466-
case self::DISCOUNT_COUNTER_TYPE_CUSTOMER:
467-
Plugin::getInstance()->getDiscounts()->clearCustomerUsageHistoryById($id);
468-
break;
469-
case self::DISCOUNT_COUNTER_TYPE_TOTAL:
470-
Plugin::getInstance()->getDiscounts()->clearDiscountUsesById($id);
471-
break;
472-
}
461+
match ($type) {
462+
self::DISCOUNT_COUNTER_TYPE_EMAIL => Plugin::getInstance()->getDiscounts()->clearEmailUsageHistoryById($id),
463+
self::DISCOUNT_COUNTER_TYPE_CUSTOMER => Plugin::getInstance()->getDiscounts()->clearCustomerUsageHistoryById($id),
464+
self::DISCOUNT_COUNTER_TYPE_TOTAL => Plugin::getInstance()->getDiscounts()->clearDiscountUsesById($id),
465+
};
473466

474467
return $this->asSuccess();
475468
}
@@ -678,8 +671,8 @@ private function _populateVariables(array &$variables): void
678671
foreach ($purchasableIds as $purchasableId) {
679672
$purchasable = Craft::$app->getElements()->getElementById((int)$purchasableId);
680673
if ($purchasable instanceof PurchasableInterface) {
681-
$class = get_class($purchasable);
682-
$purchasables[$class] = $purchasables[$class] ?? [];
674+
$class = $purchasable::class;
675+
$purchasables[$class] ??= [];
683676
$purchasables[$class][] = $purchasable;
684677
}
685678
}

src/controllers/GatewaysController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ public function actionEdit(int $id = null, ?GatewayInterface $gateway = null): R
9797
$allGatewayTypes = $gatewayService->getAllGatewayTypes();
9898

9999
// Make sure the selected gateway class is in there
100-
if ($gateway && !in_array(get_class($gateway), $allGatewayTypes, true)) {
101-
$allGatewayTypes[] = get_class($gateway);
100+
if ($gateway && !in_array($gateway::class, $allGatewayTypes, true)) {
101+
$allGatewayTypes[] = $gateway::class;
102102
}
103103

104104
$gatewayInstances = [];
105105
$gatewayOptions = [];
106106

107107
foreach ($allGatewayTypes as $class) {
108-
if (($gateway && $class === get_class($gateway)) || $class::isSelectable()) {
108+
if (($gateway && $class === $gateway::class) || $class::isSelectable()) {
109109
$gatewayInstances[$class] = $gatewayService->createGateway($class);
110110

111111
$gatewayOptions[] = [

0 commit comments

Comments
 (0)