Skip to content

Commit

Permalink
MDL-36199 reset plugin manager singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 24, 2012
1 parent 7e8ae12 commit 9854743
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/phpunit/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,14 @@ public static function reset_all_data($logchanges = false) {
}
get_fast_modinfo(0, 0, true);

// Reset other singletons.
if (class_exists('plugin_manager')) {
plugin_manager::reset_caches(true);
}
if (class_exists('available_update_checker')) {
available_update_checker::reset_caches(true);
}

// purge dataroot directory
self::reset_dataroot();

Expand Down
20 changes: 20 additions & 0 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ public static function instance() {
return self::$singletoninstance;
}

/**
* Reset any caches
* @param bool $phpunitreset
*/
public static function reset_caches($phpunitreset = false) {
if ($phpunitreset) {
self::$singletoninstance = null;
}
}

/**
* Returns a tree of known plugins and information about them
*
Expand Down Expand Up @@ -672,6 +682,16 @@ public static function instance() {
return self::$singletoninstance;
}

/**
* Reset any caches
* @param bool $phpunitreset
*/
public static function reset_caches($phpunitreset = false) {
if ($phpunitreset) {
self::$singletoninstance = null;
}
}

/**
* Returns the timestamp of the last execution of {@link fetch()}
*
Expand Down

0 comments on commit 9854743

Please sign in to comment.