Skip to content

Commit

Permalink
Dev: Don't load plugins that are not compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Sep 28, 2021
1 parent 83578af commit de93dab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions application/libraries/PluginManager/PluginManager.php
Expand Up @@ -5,6 +5,7 @@
use Yii;
use Plugin;
use ExtensionConfig;
use Exception;

/**
* Factory for limesurvey plugin objects.
Expand Down Expand Up @@ -316,7 +317,7 @@ public function scanPlugins($includeInstalledPlugins = false)
if (!$saveResult) {
// This only happens if database save fails.
$this->shutdownObject->disable();
throw new \Exception(
throw new Exception(
'Internal error: Could not save load error for plugin ' . $pluginName
);
}
Expand Down Expand Up @@ -434,7 +435,11 @@ public function loadPlugin($pluginName, $id = null)
}
} else {
if (!isset($this->plugins[$id]) || get_class($this->plugins[$id]) !== $pluginName) {
if ($this->getPluginInfo($pluginName) !== false) {
$pluginInfo = $this->getPluginInfo($pluginName);
if ($pluginInfo !== false) {
if (!$pluginInfo['isCompatible']) {
throw new Exception(gT('The plugin is not compatible with your version of LimeSurvey.'));
}
if (class_exists($pluginName)) {
$this->plugins[$id] = new $pluginName($this, $id);
if (method_exists($this->plugins[$id], 'init')) {
Expand All @@ -460,7 +465,7 @@ public function loadPlugin($pluginName, $id = null)
if (!$saveResult) {
// This only happens if database save fails.
$this->shutdownObject->disable();
throw new \Exception(
throw new Exception(
'Internal error: Could not save load error for plugin ' . $pluginName
);
}
Expand Down

0 comments on commit de93dab

Please sign in to comment.