From 32889034a09dadd3abdcc35579de1a1362033f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 4 May 2014 16:53:36 +0200 Subject: [PATCH] improved plugin activation code --- application/core/Plugins/PluginManager.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/application/core/Plugins/PluginManager.php b/application/core/Plugins/PluginManager.php index b45ec937..3eb609af 100644 --- a/application/core/Plugins/PluginManager.php +++ b/application/core/Plugins/PluginManager.php @@ -329,31 +329,26 @@ class PluginManager { * @return bool */ public function activatePlugin($pluginClass, $adminLogin = null) { - if (!is_string($pluginClass)) { - return false; - } if (!$this->isPluginClass($pluginClass)) { return false; } if ($this->isPluginActive($pluginClass)) { return false; } + /** @var Plugin $plugin */ $plugin = new $pluginClass(); - /** - * @var Plugin $plugin - */ - $this->activePlugins[$pluginClass] = $plugin; - $this->savePluginStatus($pluginClass, true); + try { $plugin->load($this->maniaControl); } catch (\Exception $e) { - $this->maniaControl->chat->sendError('Error while plugin activating ' . $pluginClass . ': ' . $e->getMessage(), $adminLogin); - $this->maniaControl->log('Error while plugin activation: ' . $pluginClass . ': ' . $e->getMessage()); - unset($this->activePlugins[$pluginClass]); + $message = "Error during Plugin Activation of '{$pluginClass}': '{$e->getMessage()}'"; + $this->maniaControl->chat->sendError($message, $adminLogin); + $this->maniaControl->log($message); $this->savePluginStatus($pluginClass, false); return false; } + $this->activePlugins[$pluginClass] = $plugin; $this->savePluginStatus($pluginClass, true); return true; }