Skip to content

Bugfix/upgrade to v5 and migrations that change sections #17262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- 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))
- 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))
- Fixed a bug where conditionally-hidden entry Title fields were still being validated as required. ([#17249](https://github.com/craftcms/cms/issues/17249))
- Fixed an error that could occur when upgrading to Craft 5. ([#17262](https://github.com/craftcms/cms/pull/17262))
- Fixed styling issues. ([#17237](https://github.com/craftcms/cms/issues/17237), [#17261](https://github.com/craftcms/cms/pull/17261))

## 5.7.5 - 2025-05-06
Expand Down
19 changes: 18 additions & 1 deletion src/migrations/m240302_212719_solo_preview_targets.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

use Craft;
use craft\db\Migration;
use craft\db\Table;
use craft\elements\Entry;
use craft\enums\CmsEdition;
use craft\helpers\ArrayHelper;
use craft\models\Section_SiteSettings;
use craft\services\ProjectConfig;

/**
* m240302_212719_solo_preview_targets migration.
Expand Down Expand Up @@ -35,7 +37,22 @@ public function safeUp(): bool
'urlFormat' => '{url}',
],
];
$entriesService->saveSection($section);

$projectConfig = Craft::$app->getProjectConfig();
$muteEvents = $projectConfig->muteEvents;
$projectConfig->muteEvents = true;

$configPath = ProjectConfig::PATH_SECTIONS . '.' . $section->uid;
$configData = $section->getConfig();
$projectConfig->set($configPath, $configData);

$projectConfig->muteEvents = $muteEvents;

$this->update(Table::SECTIONS, [
'previewTargets' => $section->previewTargets,
], [
'uid' => $section->uid,
], updateTimestamp: false);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/migrations/m250315_131608_unlimited_authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ public function safeUp(): bool
}

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

$sectionConfigs = $projectConfig->get(ProjectConfig::PATH_SECTIONS) ?? [];
foreach ($sectionConfigs as $uid => $config) {
if (!isset($config['maxAuthors'])) {
$config['maxAuthors'] = 1;
$projectConfig->set(sprintf('%s.%s', ProjectConfig::PATH_SECTIONS, $uid), $config);
}
}

$projectConfig->muteEvents = $muteEvents;

return true;
}

Expand Down