Commit 14439aca authored by Nigel Cunningham's avatar Nigel Cunningham Committed by Robert Lyon
Browse files

Bug1373226 Fix handling of missing plugin.



Fix the handling of disabling a plugin when we find that the files
for a module are missing.

Change-Id: I706a9c4fd3c86fb1a0e330bb77c40d5e6d888a52
Signed-off-by: default avatarNigel Cunningham <nigelc@catalyst-au.net>
parent 6750fd37
......@@ -40,9 +40,6 @@ foreach (array_keys($plugins) as $plugin) {
$key = blocktype_single_to_namespaced($i->name, $i->artefactplugin);
}
if (!safe_require_plugin($plugin, $key)) {
if ($i->active) {
$SESSION->add_error_msg(get_string('missingplugindisabled', 'admin', hsc("$plugin:$key")));
}
continue;
}
$plugins[$plugin]['installed'][$key] = array(
......
......@@ -49,10 +49,9 @@ class PluginBlocktypeInbox extends SystemBlocktype {
$maxitems = isset($configdata['maxitems']) ? $configdata['maxitems'] : 5;
// check if multirecipientnotification plugin is active or if we proceed here
if (record_exists('artefact_installed', 'name', 'multirecipientnotification', 'active', '1')) {
if (record_exists('artefact_installed', 'name', 'multirecipientnotification', 'active', '1') && safe_require_plugin('artefact', 'multirecipientnotification')) {
global $USER;
$userid = $USER->get('id');
safe_require('artefact', 'multirecipientnotification');
$activitylist = activitylistin(join(',', $desiredtypes), $maxitems);
$records = array();
......
......@@ -1468,7 +1468,14 @@ function safe_require_plugin($plugintype, $pluginname, $filename='lib.php', $fun
}
catch (SystemException $e) {
if (get_field($plugintype . '_installed', 'active', 'name', $pluginname) == 1) {
global $SESSION;
set_field($plugintype . '_installed', 'active', 0, 'name', $pluginname);
$SESSION->add_error_msg(get_string('missingplugindisabled', 'admin', hsc("$plugintype:$pluginname")));
// Reset the plugin cache.
plugins_installed('', TRUE, TRUE);
// Alert site admins that the plugin is broken so was disabled
$message = new stdClass();
$message->users = get_column('usr', 'id', 'admin', 1);
......@@ -1520,11 +1527,17 @@ function plugin_types_installed() {
*
* @param string $plugintype type of plugin
* @param bool $all - return all (true) or only active (false) plugins
* @param bool $reset - whether to reset the cache (when disabling a plugin due to unavailability)
* @return array of objects with fields (version (int), release (str), active (bool), name (str))
*/
function plugins_installed($plugintype, $all=false) {
function plugins_installed($plugintype, $all=false, $reset=false) {
static $records = array();
if ($reset) {
$records = array();
return false;
}
if (defined('INSTALLER') || defined('TESTSRUNNING') || !isset($records[$plugintype][true])) {
$sort = $plugintype == 'blocktype' ? 'artefactplugin,name' : 'name';
......
......@@ -2769,10 +2769,11 @@ function right_nav() {
foreach (array('artefact', 'interaction', 'module') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
safe_require($plugintype, $plugin->name);
$plugin_nav_menu = call_static_method(generate_class_name($plugintype, $plugin->name),
'right_nav_menu_items');
$menu = array_merge($menu, $plugin_nav_menu);
if (safe_require_plugin($plugintype, $plugin->name)) {
$plugin_nav_menu = call_static_method(generate_class_name($plugintype, $plugin->name),
'right_nav_menu_items');
$menu = array_merge($menu, $plugin_nav_menu);
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment