1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 10:26:17 +02:00

MDL-36386 cache: upgrades now trigger definitions to be updated

This commit is contained in:
Sam Hemelryk 2012-11-07 10:36:09 +13:00
parent 6109f2112c
commit 75af47ee1e
4 changed files with 33 additions and 10 deletions

@ -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();
}
}

23
cache/locallib.php vendored

@ -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;
}
}
}

@ -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);
}

@ -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