From ea30714acff275cff51930d6f4312722e4cb2916 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Mon, 16 Nov 2015 20:25:51 +0000 Subject: show an error message if installing a plugin fails --- core/Plugin/Manager.php | 10 ++-------- core/Plugin/PluginException.php | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'core') diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 010838acf8..150151ee3e 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -440,16 +440,10 @@ class Manager public function installLoadedPlugins() { Log::debug("Loaded plugins: " . implode(", ", array_keys($this->getLoadedPlugins()))); - $messages = array(); + foreach ($this->getLoadedPlugins() as $plugin) { - try { - $this->installPluginIfNecessary($plugin); - } catch (\Exception $e) { - $messages[] = $e->getMessage(); - } + $this->installPluginIfNecessary($plugin); } - - return $messages; } /** diff --git a/core/Plugin/PluginException.php b/core/Plugin/PluginException.php index 90aa03a342..83816ca365 100644 --- a/core/Plugin/PluginException.php +++ b/core/Plugin/PluginException.php @@ -8,14 +8,28 @@ namespace Piwik\Plugin; +use Piwik\Common; + class PluginException extends \Exception { public function __construct($pluginName, $message) { - parent::__construct("There was a problem installing the plugin " . $pluginName . ": " . $message . " - If this plugin has already been installed, and if you want to hide this message, you must add the following line under the - [PluginsInstalled] - entry in your config/config.ini.php file: - PluginsInstalled[] = $pluginName"); + $pluginName = Common::sanitizeInputValue($pluginName); + $message = Common::sanitizeInputValue($message); + + parent::__construct("There was a problem installing the plugin $pluginName:

+ $message +

+ If you want to hide this message you must remove the following line under the [Plugins] entry in your + 'config/config.ini.php' file to disable this plugin.
+ Plugins[] = $pluginName +

If this plugin has already been installed, you must add the following line under the + [PluginsInstalled] entry in your 'config/config.ini.php' file:
+ PluginsInstalled[] = $pluginName"); + } + + public function isHtmlMessage() + { + return true; } } -- cgit v1.2.3