From de93dab2850deeb0e21e13d815eceff07508c3ae Mon Sep 17 00:00:00 2001 From: Olle Haerstedt Date: Tue, 28 Sep 2021 17:11:16 +0200 Subject: [PATCH] Dev: Don't load plugins that are not compatible --- application/libraries/PluginManager/PluginManager.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/application/libraries/PluginManager/PluginManager.php b/application/libraries/PluginManager/PluginManager.php index b26f8f3e237..4d491779976 100644 --- a/application/libraries/PluginManager/PluginManager.php +++ b/application/libraries/PluginManager/PluginManager.php @@ -5,6 +5,7 @@ use Yii; use Plugin; use ExtensionConfig; +use Exception; /** * Factory for limesurvey plugin objects. @@ -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 ); } @@ -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')) { @@ -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 ); }