Skip to content

Commit

Permalink
Merge branch '5.x' into 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Dec 3, 2024
2 parents 2d14040 + 5a25d30 commit c69ca44
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: ci
uses: craftcms/.github/.github/workflows/ci.yml@v3
with:
php_version: '8.2'
php_version: '["8.2", "8.3"]'
craft_version: '5'
node_version: '20'
jobs: '["ecs", "phpstan", "prettier", "tests"]'
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Release Notes for Craft Commerce

## Unreleased
## 5.2.7 - 2024-11

- Fixed a bug where users could access the Commerce user screen when the current user didn’t have permission.
- Fixed an error that occurred on the Orders index page when running Craft CMS 5.5.4 or later. ([#3793](https://github.com/craftcms/commerce/issues/3793))
- Fixed a bug where a structured product type’s “Max Levels” setting wasn’t being respected. ([#3785](https://github.com/craftcms/commerce/issues/3785))
- Fixed an information disclosure vulnerability.

## 5.2.6 - 2024-11-26

Expand Down
369 changes: 183 additions & 186 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static function editions(): array
/**
* @inheritDoc
*/
public string $schemaVersion = '5.2.0.5';
public string $schemaVersion = '5.2.7.0';

/**
* @inheritdoc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace craft\commerce\migrations;

use craft\commerce\db\Table;
use craft\db\Migration;
use craft\db\Query;
use craft\db\Table as CraftTable;

/**
* m241128_174712_fix_maxLevels_structured_productTypes migration.
*/
class m241128_174712_fix_maxLevels_structured_productTypes extends Migration
{
/**
* @inheritdoc
*/
public function safeUp(): bool
{
// Get all product types from Commerce project config
$structuredProductTypesWithMaxLevels = (new Query())
->from(Table::PRODUCTTYPES)
->where(['isStructure' => true])
->andWhere(['not', ['maxLevels' => null]])
->collect();

// Loop through and update the `maxLevels` column in the `structures` table
$structuredProductTypesWithMaxLevels->each(function($productType) {
$this->update(CraftTable::STRUCTURES, ['maxLevels' => $productType['maxLevels']], ['id' => $productType['structureId']]);
});

return true;
}

/**
* @inheritdoc
*/
public function safeDown(): bool
{
echo "m241128_174712_fix_maxLevels_structured_productTypes cannot be reverted.\n";
return false;
}
}
1 change: 1 addition & 0 deletions src/services/Plans.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function getPlansByGatewayId(int $gatewayId): array
*
* @return Plan[]
* @deprecated in 4.0. Use [[getPlansByGatewayId]] instead.
* TODO: remove in 6.0
*/
public function getAllGatewayPlans(int $gatewayId): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/services/ProductTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public function handleChangedProductType(ConfigEvent $event): void
$structureUid = $data['structure']['uid'];
$structure = Craft::$app->getStructures()->getStructureByUid($structureUid, true) ?? new Structure(['uid' => $structureUid]);
$isNewStructure = empty($structure->id);
$structure->maxLevels = $data['structure']['maxLevels'] ?? null;
$structure->maxLevels = $data['maxLevels'] ?? null;
Craft::$app->getStructures()->saveStructure($structure);
$productTypeRecord->structureId = $structure->id;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/templates/orders/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

{% block initJs %}
Craft.elementIndex = Craft.createElementIndex('{{ elementType|e("js") }}', $('#page-container'), {
elementTypeName: '{{ elementInstance.displayName()|e("js") }}',
elementTypePluralName: '{{ elementInstance.pluralDisplayName()|e("js") }}',
elementTypeName: '{{ elementDisplayName ?? (elementInstance.displayName())|e("js") }}',
elementTypePluralName: '{{ elementPluralDisplayName ?? (elementInstance.pluralDisplayName())|e("js") }}',
context: '{{ context }}',
storageKey: 'elementindex.{{ elementType|e("js") }}',
toolbarSelector: '#toolbar',
Expand Down

0 comments on commit c69ca44

Please sign in to comment.