Skip to content
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

check if schema version has changed against the old version #16574

Merged
merged 6 commits into from
Feb 2, 2025
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
13 changes: 5 additions & 8 deletions src/services/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,14 +854,11 @@ public function updatePluginVersionInfo(PluginInterface $plugin): void
$this->_storedPluginInfo[$plugin->id]['schemaVersion'] = $plugin->schemaVersion;
}

// Only update the schema version if it's changed from what's in the file,
// so we don't accidentally overwrite other pending changes
$projectConfig = Craft::$app->getProjectConfig();
$key = ProjectConfig::PATH_PLUGINS . ".$plugin->id.schemaVersion";

if ($projectConfig->get($key, true) !== $plugin->schemaVersion) {
Craft::$app->getProjectConfig()->set($key, $plugin->schemaVersion, "Update plugin schema version for “{$plugin->handle}”");
}
Craft::$app->getProjectConfig()->set(
sprintf('%s.%s.schemaVersion', ProjectConfig::PATH_PLUGINS, $plugin->id),
$plugin->schemaVersion,
"Update plugin schema version for “{$plugin->handle}”",
);
}

/**
Expand Down
11 changes: 5 additions & 6 deletions src/services/Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,11 @@ public function updateCraftVersionInfo(): bool

Craft::$app->saveInfo($info);

// Only update the schema version if it's changed from what's in the file,
// so we don't accidentally overwrite other pending changes
$projectConfig = Craft::$app->getProjectConfig();
if ($projectConfig->get(ProjectConfig::PATH_SCHEMA_VERSION, true) !== $info->schemaVersion) {
brandonkelly marked this conversation as resolved.
Show resolved Hide resolved
Craft::$app->getProjectConfig()->set(ProjectConfig::PATH_SCHEMA_VERSION, $info->schemaVersion, 'Update Craft schema version');
}
Craft::$app->getProjectConfig()->set(
ProjectConfig::PATH_SCHEMA_VERSION,
$info->schemaVersion,
'Update Craft schema version',
);

$this->_isCraftUpdatePending = null;

Expand Down