MDL-43033 cache: fixed mode map event invalidation scenario

This commit is contained in:
Sam Hemelryk 2013-11-26 12:17:33 +13:00
parent 6dbe2df208
commit bf77c0b273

View File

@ -235,15 +235,28 @@ class cache_factory {
*/
public function create_cache(cache_definition $definition) {
$class = $definition->get_cache_class();
if ($this->is_initialising()) {
if ($this->is_initialising() || $this->stores_disabled()) {
// Do nothing we just want the dummy store.
$stores = array();
$stores = array($this->create_dummy_store($definition));
} else {
$stores = cache_helper::get_cache_stores($definition);
}
if (count($stores) === 0) {
// Hmm no stores, better provide a dummy store to mimick functionality. The dev will be none the wiser.
$stores[] = $this->create_dummy_store($definition);
if (count($stores) === 0) {
// No suitable stores we found for the definition. We need to come up with a sensible default.
// If this has happened we can be sure that the user has mapped custom stores to either the
// mode of the definition. The first alternative to try is the system default for the mode.
// e.g. the default file store instance for application definitions.
$config = $this->create_config_instance();
foreach ($config->get_stores($definition->get_mode()) as $name => $details) {
if (!empty($details['default'])) {
$stores[] = $this->create_store_from_config($name, $details, $definition);
break;
}
}
if (count($stores) === 0) {
// Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser.
$stores[] = $this->create_dummy_store($definition);
}
}
}
$loader = null;
if ($definition->has_data_source()) {