Skip to content

Commit 086a56a

Browse files
authored
Merge pull request #17262 from craftcms/bugfix/upgrade-to-v5-and-migrations-that-change-sections
Bugfix/upgrade to v5 and migrations that change sections
2 parents 91904b0 + a41d92b commit 086a56a

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Fixed an error that could occur when attempting to edit a newly-created nested entry within a Matrix field set to the element index view mode. ([#17231](https://github.com/craftcms/cms/pull/17231))
1616
- Fixed a bug where setting up two-step verification for an impersonated user would result in the original user getting logged back in. ([#17245](https://github.com/craftcms/cms/pull/17245))
1717
- Fixed a bug where conditionally-hidden entry Title fields were still being validated as required. ([#17249](https://github.com/craftcms/cms/issues/17249))
18+
- Fixed an error that could occur when upgrading to Craft 5. ([#17262](https://github.com/craftcms/cms/pull/17262))
1819
- Fixed styling issues. ([#17237](https://github.com/craftcms/cms/issues/17237), [#17261](https://github.com/craftcms/cms/pull/17261))
1920

2021
## 5.7.5 - 2025-05-06

src/migrations/m240302_212719_solo_preview_targets.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
use Craft;
66
use craft\db\Migration;
7+
use craft\db\Table;
78
use craft\elements\Entry;
89
use craft\enums\CmsEdition;
910
use craft\helpers\ArrayHelper;
1011
use craft\models\Section_SiteSettings;
12+
use craft\services\ProjectConfig;
1113

1214
/**
1315
* m240302_212719_solo_preview_targets migration.
@@ -35,7 +37,22 @@ public function safeUp(): bool
3537
'urlFormat' => '{url}',
3638
],
3739
];
38-
$entriesService->saveSection($section);
40+
41+
$projectConfig = Craft::$app->getProjectConfig();
42+
$muteEvents = $projectConfig->muteEvents;
43+
$projectConfig->muteEvents = true;
44+
45+
$configPath = ProjectConfig::PATH_SECTIONS . '.' . $section->uid;
46+
$configData = $section->getConfig();
47+
$projectConfig->set($configPath, $configData);
48+
49+
$projectConfig->muteEvents = $muteEvents;
50+
51+
$this->update(Table::SECTIONS, [
52+
'previewTargets' => $section->previewTargets,
53+
], [
54+
'uid' => $section->uid,
55+
], updateTimestamp: false);
3956
}
4057
}
4158
}

src/migrations/m250315_131608_unlimited_authors.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ public function safeUp(): bool
2424
}
2525

2626
$projectConfig = Craft::$app->getProjectConfig();
27-
$sectionConfigs = $projectConfig->get(ProjectConfig::PATH_SECTIONS) ?? [];
27+
$muteEvents = $projectConfig->muteEvents;
28+
$projectConfig->muteEvents = true;
2829

30+
$sectionConfigs = $projectConfig->get(ProjectConfig::PATH_SECTIONS) ?? [];
2931
foreach ($sectionConfigs as $uid => $config) {
3032
if (!isset($config['maxAuthors'])) {
3133
$config['maxAuthors'] = 1;
3234
$projectConfig->set(sprintf('%s.%s', ProjectConfig::PATH_SECTIONS, $uid), $config);
3335
}
3436
}
3537

38+
$projectConfig->muteEvents = $muteEvents;
39+
3640
return true;
3741
}
3842

0 commit comments

Comments
 (0)