Permalink
Browse files

MDL-25290 cache: Made handling of cache locks when writing config mor…

…e robust
  • Loading branch information...
1 parent 8dbfbd7 commit 573a6c8eb3d656323612cf0265311b6d90512236 Sam Hemelryk committed Sep 26, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 cache/locallib.php
View
20 cache/locallib.php
@@ -81,8 +81,19 @@ protected function config_save() {
// We need to create a temporary cache lock instance for use here. Remember we are generating the config file
// it doesn't exist and thus we can't use the normal API for this (it'll just try to use config).
+ $lockconf = reset($this->configlocks);
+ if ($lockconf === false) {
+ debugging('Your cache configuration file is out of date and needs to be refreshed.', DEBUG_DEVELOPER);
+ // Use the default
+ $lockconf = array(
+ 'name' => 'cachelock_file_default',
+ 'type' => 'cachelock_file',
+ 'dir' => 'filelocks',
+ 'default' => true
+ );
+ }
$factory = cache_factory::instance();
- $locking = $factory->create_lock_instance(reset($this->configlocks));
+ $locking = $factory->create_lock_instance($lockconf);
if ($locking->lock('configwrite', 'config', true)) {
// Its safe to use w mode here because we have already acquired the lock.
$handle = fopen($cachefile, 'w');
@@ -515,12 +526,6 @@ public static function get_store_summaries() {
ksort($default);
$return = $return + $default;
- foreach ($instance->get_mode_mappings() as $mapping) {
- if (!array_key_exists($mapping['store'], $return)) {
- continue;
- }
- $return[$mapping['store']]['mappings']++;
- }
foreach ($instance->get_definition_mappings() as $mapping) {
if (!array_key_exists($mapping['store'], $return)) {
continue;
@@ -738,7 +743,6 @@ public static function get_add_store_form($plugin) {
$config = cache_config::instance();
$locks = array();
foreach ($config->get_locks() as $lock => $conf) {
- debug($conf);
if (!empty($conf['default'])) {
$name = get_string($lock, 'cache');
} else {

0 comments on commit 573a6c8

Please sign in to comment.