Skip to content

Commit

Permalink
Fixed #7191
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 5, 2020
1 parent cbc13c2 commit 85c0e07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,7 @@
- Fixed a bug where WebP images were not transformable, even if the server was configured for it. ([#7170](https://github.com/craftcms/cms/issues/7170))
- Fixed a bug where the image editor could save an image incorrectly, if the `upscaleImages` config setting was set to `false`.
- Fixed a bug where it wasn’t possible to install a plugin if it had a row in the `plugins` table, but it wasn’t in the project config. ([#7229](https://github.com/craftcms/cms/issues/7229))
- Fixed a bug where Craft wasn’t always respecting plugins’ `minVersionRequired`. ([#7191](https://github.com/craftcms/cms/issues/7191))

## 3.5.16 - 2020-11-24

Expand Down
32 changes: 18 additions & 14 deletions src/services/Plugins.php
Expand Up @@ -231,21 +231,25 @@ public function loadPlugins()
}

if ($plugin !== null) {
// If we're not updating, check if the plugin's version number changed, but not its schema version.
if (!Craft::$app->getIsInMaintenanceMode() && $this->hasPluginVersionNumberChanged($plugin) && !$this->doesPluginRequireDatabaseUpdate($plugin)) {
if (
$plugin->minVersionRequired &&
strpos($row['version'], 'dev-') !== 0 &&
!StringHelper::endsWith($row['version'], '-dev') &&
version_compare($row['version'], $plugin->minVersionRequired, '<')
) {
throw new HttpException(200, Craft::t('app', 'You need to be on at least {plugin} {version} before you can update to {plugin} {targetVersion}.', [
'version' => $plugin->minVersionRequired,
'targetVersion' => $plugin->version,
'plugin' => $plugin->name
]));
}
$hasVersionChanged = $this->hasPluginVersionNumberChanged($plugin);

// If the plugin’s version just changed, make sure the old version is >= the min allowed version
if (
$hasVersionChanged &&
$plugin->minVersionRequired &&
strpos($row['version'], 'dev-') !== 0 &&
!StringHelper::endsWith($row['version'], '-dev') &&
version_compare($row['version'], $plugin->minVersionRequired, '<')
) {
throw new HttpException(200, Craft::t('app', 'You need to be on at least {plugin} {version} before you can update to {plugin} {targetVersion}.', [
'version' => $plugin->minVersionRequired,
'targetVersion' => $plugin->version,
'plugin' => $plugin->name
]));
}

// If we're not updating, check if the plugin's version number changed, but not its schema version.
if (!Craft::$app->getIsInMaintenanceMode() && $hasVersionChanged && !$this->doesPluginRequireDatabaseUpdate($plugin)) {
// Update our record of the plugin's version number
Db::update(Table::PLUGINS, [
'version' => $plugin->getVersion(),
Expand Down

0 comments on commit 85c0e07

Please sign in to comment.