From 9854743221d1e83ee5db66f1b3a83045076ab44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0koda?= Date: Thu, 25 Oct 2012 00:55:10 +0800 Subject: [PATCH] MDL-36199 reset plugin manager singletons --- lib/phpunit/classes/util.php | 8 ++++++++ lib/pluginlib.php | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/phpunit/classes/util.php b/lib/phpunit/classes/util.php index 8e44d8088cb..1fa42d4a46c 100644 --- a/lib/phpunit/classes/util.php +++ b/lib/phpunit/classes/util.php @@ -648,6 +648,14 @@ class phpunit_util { } 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(); diff --git a/lib/pluginlib.php b/lib/pluginlib.php index cb35acab04b..9191e7c36ac 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -86,6 +86,16 @@ class plugin_manager { 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 * @@ -672,6 +682,16 @@ class available_update_checker { 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()} *