From 7c9b837ea9a1d2911cfd8eb4af681a3d7784a0b7 Mon Sep 17 00:00:00 2001 From: David Mudrak <david@moodle.com> Date: Wed, 6 Apr 2011 11:14:52 +0200 Subject: [PATCH] MDL-26784 Plugin manager: make sure that filter_active already exists In case of upgrade from 1.9, the table filter_active does not exist yet. There already was this checked at another place but it is needed to test the table existence here as well. --- lib/pluginlib.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/pluginlib.php b/lib/pluginlib.php index fa1d8bfb585..17e829849f2 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -871,7 +871,7 @@ class plugintype_filter extends plugintype_base implements plugintype_interface * @see plugintype_interface::get_plugins() */ public static function get_plugins($type, $typerootdir, $typeclass) { - global $CFG; + global $CFG, $DB; $filters = array(); @@ -894,17 +894,21 @@ class plugintype_filter extends plugintype_base implements plugintype_interface $filters[$plugin->name] = $plugin; } - // make sure that all installed filters are registered $globalstates = self::get_global_states(); - $needsreload = false; - foreach (array_keys($installed) as $filterlegacyname) { - if (!isset($globalstates[self::normalize_legacy_name($filterlegacyname)])) { - filter_set_global_state($filterlegacyname, TEXTFILTER_DISABLED); - $needsreload = true; + + if ($DB->get_manager()->table_exists('filter_active')) { + // if we're upgrading from 1.9, the table does not exist yet + // if it does, make sure that all installed filters are registered + $needsreload = false; + foreach (array_keys($installed) as $filterlegacyname) { + if (!isset($globalstates[self::normalize_legacy_name($filterlegacyname)])) { + filter_set_global_state($filterlegacyname, TEXTFILTER_DISABLED); + $needsreload = true; + } + } + if ($needsreload) { + $globalstates = self::get_global_states(true); } - } - if ($needsreload) { - $globalstates = self::get_global_states(true); } // make sure that all registered filters are installed, just in case