diff --git a/cache/classes/helper.php b/cache/classes/helper.php index dfb3346bcfc..9a03556bad4 100644 --- a/cache/classes/helper.php +++ b/cache/classes/helper.php @@ -453,4 +453,19 @@ class cache_helper { public static function hash_key($key) { return crc32($key); } + + /** + * Finds all definitions and updates them within the cache config file. + * + * @param bool $coreonly If set to true only core definitions will be updated. + */ + public static function update_definitions($coreonly = false) { + global $CFG; + // Include locallib + require_once($CFG->dirroot.'/cache/locallib.php'); + // First update definitions + cache_config_writer::update_definitions($coreonly); + // Second reset anything we have already initialised to ensure we're all up to date. + cache_factory::reset(); + } } \ No newline at end of file diff --git a/cache/locallib.php b/cache/locallib.php index 8b6c3ab6f8b..5b2d8aea2cf 100644 --- a/cache/locallib.php +++ b/cache/locallib.php @@ -364,18 +364,21 @@ class cache_config_writer extends cache_config { * Updates the definition in the configuration from those found in the cache files. * * Calls config_save further down, you should redirect immediately or asap after calling this method. + * + * @param bool $coreonly If set to true only core definitions will be updated. */ - public static function update_definitions() { + public static function update_definitions($coreonly = false) { $config = self::instance(); - $config->write_definitions_to_cache(self::locate_definitions()); + $config->write_definitions_to_cache(self::locate_definitions($coreonly)); } /** * Locates all of the definition files. * + * @param bool $coreonly If set to true only core definitions will be updated. * @return array */ - protected static function locate_definitions() { + protected static function locate_definitions($coreonly = false) { global $CFG; $files = array(); @@ -383,12 +386,14 @@ class cache_config_writer extends cache_config { $files['core'] = $CFG->dirroot.'/lib/db/caches.php'; } - $plugintypes = get_plugin_types(); - foreach ($plugintypes as $type => $location) { - $plugins = get_plugin_list_with_file($type, 'db/caches.php'); - foreach ($plugins as $plugin => $filepath) { - $component = clean_param($type.'_'.$plugin, PARAM_COMPONENT); // Standardised plugin name. - $files[$component] = $filepath; + if (!$coreonly) { + $plugintypes = get_plugin_types(); + foreach ($plugintypes as $type => $location) { + $plugins = get_plugin_list_with_file($type, 'db/caches.php'); + foreach ($plugins as $plugin => $filepath) { + $component = clean_param($type.'_'.$plugin, PARAM_COMPONENT); // Standardised plugin name. + $files[$component] = $filepath; + } } } diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 149fc01fba9..7bd0d9793a8 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -1492,6 +1492,8 @@ function upgrade_core($version, $verbose) { external_update_descriptions('moodle'); events_update_definition('moodle'); message_update_providers('moodle'); + // Update core definitions. + cache_helper::update_definitions(true); // Reset caches again, just to be sure purge_all_caches(); @@ -1525,6 +1527,7 @@ function upgrade_noncore($verbose) { foreach ($plugintypes as $type=>$location) { upgrade_plugins($type, 'print_upgrade_part_start', 'print_upgrade_part_end', $verbose); } + cache_helper::update_definitions(); } catch (Exception $ex) { upgrade_handle_exception($ex); } diff --git a/version.php b/version.php index 4904073e6d7..b6cffad1e95 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012110101.00; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012110700.00; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes