diff options
author | Jehan-Guillaume (ioguix) de Rorthais | 2013-04-05 10:54:37 +0000 |
---|---|---|
committer | Jehan-Guillaume (ioguix) de Rorthais | 2013-04-05 12:39:57 +0000 |
commit | d747d6324d1ffdf835fd11071f6b97d2972f2ba9 (patch) | |
tree | 77295135b4c092c5e0792272485fc8fe8f4e644e | |
parent | d5e9a584cf4fb9f13554bda3eff350289d96f564 (diff) |
Add try/catch blocks around plugin instanciation so they can throw an exception if needed.
This is usefull if a plugin don't want to start for some reasons.
Throwing an exception from the plugin constructors allows to remove this
plugin entirely during the script execution.
-rw-r--r-- | classes/PluginManager.php | 9 | ||||
-rw-r--r-- | libraries/lib.inc.php | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/classes/PluginManager.php b/classes/PluginManager.php index 794f8c7b..33603c75 100644 --- a/classes/PluginManager.php +++ b/classes/PluginManager.php @@ -39,8 +39,13 @@ class PluginManager { // Verify is the activated plugin exists if (file_exists($plugin_file)) { include_once($plugin_file); - $plugin = new $activated_plugin($language); - $this->add_plugin($plugin); + try { + $plugin = new $activated_plugin($language); + $this->add_plugin($plugin); + } + catch (Exception $e) { + continue; + } } else { printf($lang['strpluginnotfound']."\t\n", $activated_plugin); exit; diff --git a/libraries/lib.inc.php b/libraries/lib.inc.php index 99a44f64..0a05f101 100644 --- a/libraries/lib.inc.php +++ b/libraries/lib.inc.php @@ -185,6 +185,9 @@ exit; } + // Manage the plugins + require_once('./classes/PluginManager.php'); + // Create data accessor object, if necessary if (!isset($_no_db_connection)) { if (!isset($_REQUEST['server'])) { @@ -199,6 +202,7 @@ // Redirect to the login form if not logged in if (!isset($_server_info['username'])) { + $plugin_manager = new PluginManager($_language); include('./login.php'); exit; } @@ -232,7 +236,5 @@ } } - // Manage the plugins - require_once('./classes/PluginManager.php'); $plugin_manager = new PluginManager($_language); ?> |