Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-30545/ MDL-36199 reset plugin manager singletons

  • Loading branch information...
commit 95f6a022ca6627bf6853b71bc8c3783ab8cb32da 1 parent af698e6
@skodak skodak authored danpoltawski committed
Showing with 28 additions and 0 deletions.
  1. +8 −0 lib/phpunit/classes/util.php
  2. +20 −0 lib/pluginlib.php
View
8 lib/phpunit/classes/util.php
@@ -625,6 +625,14 @@ public static function reset_all_data($logchanges = false) {
$reset = 'reset';
get_fast_modinfo($reset);
+ // 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();
View
20 lib/pluginlib.php
@@ -89,6 +89,16 @@ public static function instance() {
}
/**
+ * 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
*
* @param bool $disablecache force reload, cache can be used otherwise
@@ -650,6 +660,16 @@ public static function instance() {
}
/**
+ * 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()}
*
* @return int|null null if it has never been executed or we don't known
Please sign in to comment.
Something went wrong with that request. Please try again.