Skip to content

Commit

Permalink
Fixed #16314
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 13, 2024
1 parent 7ed7634 commit 183c48c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Fixed a bug where field conditions weren’t taking effect within Matrix fields set to inline-editable blocks mode, if the owner element didn’t support drafts. ([#16315](https://github.com/craftcms/cms/pull/16315))
- Fixed a bug where Matrix fields’ entry types weren’t maintaining their original block type order when upgrading to Craft 5. ([#16314](https://github.com/craftcms/cms/issues/16314))

## 5.5.6.1 - 2024-12-11

Expand Down
8 changes: 7 additions & 1 deletion src/migrations/m230617_070415_entrify_matrix_blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use craft\models\EntryType;
use craft\models\FieldLayout;
use craft\services\ProjectConfig;
use Illuminate\Support\Arr;
use yii\db\Exception as DbException;
use yii\helpers\Inflector;

Expand Down Expand Up @@ -90,8 +91,13 @@ public function safeUp(): bool
foreach ($fieldConfigs as $fieldPath => $fieldConfig) {
$fieldUid = ArrayHelper::lastValue(explode('.', $fieldPath));
$fieldEntryTypes = [];
$blockTypeConfigsByField[$fieldUid] ??= [];
$blockTypeConfigsByField[$fieldUid] = Arr::sort(
$blockTypeConfigsByField[$fieldUid],
fn(array $config) => $config['sortOrder'] ?? 0,
);

foreach ($blockTypeConfigsByField[$fieldUid] ?? [] as $blockTypeUid => $blockTypeConfig) {
foreach ($blockTypeConfigsByField[$fieldUid] as $blockTypeUid => $blockTypeConfig) {
$entryType = $newEntryTypes[] = $fieldEntryTypes[] = new EntryType([
'uid' => $blockTypeUid,
'name' => $this->uniqueName($blockTypeConfig['name'], $entryTypeNames),
Expand Down

0 comments on commit 183c48c

Please sign in to comment.