Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mudrd8mz committed Apr 6, 2011
1 parent 91dedc3 commit 7c9b837
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/pluginlib.php
Expand Up @@ -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();

Expand All @@ -894,17 +894,21 @@ public static function get_plugins($type, $typerootdir, $typeclass) {
$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
Expand Down

0 comments on commit 7c9b837

Please sign in to comment.