Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-38565 cache: upgrade code to amend default stores

Conflicts:
	version.php
  • Loading branch information...
commit 312ad653e9ce7272e31a91f9f634895142b2d96c 1 parent 73433c0
@samhemelryk samhemelryk authored
Showing with 56 additions and 27 deletions.
  1. +47 −26 cache/locallib.php
  2. +8 −0 lib/db/upgrade.php
  3. +1 −1  version.php
View
73 cache/locallib.php
@@ -340,32 +340,7 @@ public static function create_default_configuration() {
require_once($CFG->dirroot.'/cache/stores/static/lib.php');
$writer = new self;
- $writer->configstores = array(
- 'default_application' => array(
- 'name' => 'default_application',
- 'plugin' => 'file',
- 'configuration' => array(),
- 'features' => cachestore_file::get_supported_features(),
- 'modes' => cachestore_file::get_supported_modes(),
- 'default' => true,
- ),
- 'default_session' => array(
- 'name' => 'default_session',
- 'plugin' => 'session',
- 'configuration' => array(),
- 'features' => cachestore_session::get_supported_features(),
- 'modes' => cachestore_session::get_supported_modes(),
- 'default' => true,
- ),
- 'default_request' => array(
- 'name' => 'default_request',
- 'plugin' => 'static',
- 'configuration' => array(),
- 'features' => cachestore_static::get_supported_features(),
- 'modes' => cachestore_static::get_supported_modes(),
- 'default' => true,
- )
- );
+ $writer->configstores = self::get_default_stores();
$writer->configdefinitions = self::locate_definitions();
$writer->configmodemappings = array(
array(
@@ -405,6 +380,52 @@ public static function create_default_configuration() {
}
/**
+ * Returns an array of default stores for use.
+ *
+ * @return array
+ */
+ protected static function get_default_stores() {
+ return array(
+ 'default_application' => array(
+ 'name' => 'default_application',
+ 'plugin' => 'file',
+ 'configuration' => array(),
+ 'features' => cachestore_file::get_supported_features(),
+ 'modes' => cachestore_file::get_supported_modes(),
+ 'default' => true,
+ ),
+ 'default_session' => array(
+ 'name' => 'default_session',
+ 'plugin' => 'session',
+ 'configuration' => array(),
+ 'features' => cachestore_session::get_supported_features(),
+ 'modes' => cachestore_session::get_supported_modes(),
+ 'default' => true,
+ ),
+ 'default_request' => array(
+ 'name' => 'default_request',
+ 'plugin' => 'static',
+ 'configuration' => array(),
+ 'features' => cachestore_static::get_supported_features(),
+ 'modes' => cachestore_static::get_supported_modes(),
+ 'default' => true,
+ )
+ );
+ }
+
+ /**
+ * Updates the default stores within the MUC config file.
+ */
+ public static function update_default_config_stores() {
+ $factory = cache_factory::instance();
+ $factory->updating_started();
+ $config = $factory->create_config_instance(true);
+ $config->configstores = array_merge($config->configstores, self::get_default_stores());
+ $config->config_save();
+ $factory->updating_finished();
+ }
+
+ /**
* 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.
View
8 lib/db/upgrade.php
@@ -1697,5 +1697,13 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012120303.06);
}
+ if ($oldversion < 2012120303.08) {
+ require_once($CFG->dirroot.'/cache/locallib.php');
+ // The features bin needs updating.
+ cache_config_writer::update_default_config_stores();
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2012120303.08);
+ }
+
return true;
}
View
2  version.php
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2012120303.07; // 20121203 = branching date YYYYMMDD - do not modify!
+$version = 2012120303.08; // 20121203 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches
// .XX = incremental changes
Please sign in to comment.
Something went wrong with that request. Please try again.