Skip to content
Browse files

Merge branch '43349-24' of git://github.com/samhemelryk/moodle into M…

…OODLE_24_STABLE
  • Loading branch information...
2 parents a902db8 + 87f62d8 commit e9576ab6b4f4f68c7a047d39e3352df9a0deaae9 @danpoltawski danpoltawski committed
Showing with 10 additions and 3 deletions.
  1. +8 −2 cache/classes/factory.php
  2. +2 −1 cache/classes/helper.php
View
10 cache/classes/factory.php
@@ -236,6 +236,11 @@ public function create_cache_from_params($mode, $component, $area, array $identi
public function create_cache(cache_definition $definition) {
$class = $definition->get_cache_class();
$stores = cache_helper::get_stores_suitable_for_definition($definition);
+ foreach ($stores as $key => $store) {
+ if (!$store::are_requirements_met()) {
+ unset($stores[$key]);
+ }
+ }
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);
@@ -253,7 +258,7 @@ public function create_cache(cache_definition $definition) {
/**
* Creates a store instance given its name and configuration.
*
- * If the store has already been instantiated then the original objetc will be returned. (reused)
+ * If the store has already been instantiated then the original object will be returned. (reused)
*
* @param string $name The name of the store (must be unique remember)
* @param array $details
@@ -267,8 +272,9 @@ public function create_store_from_config($name, array $details, cache_definition
$store = new $class($details['name'], $details['configuration']);
$this->stores[$name] = $store;
}
+ /* @var cache_store $store */
$store = $this->stores[$name];
- if (!$store->is_ready() || !$store->is_supported_mode($definition->get_mode())) {
+ if (!$store::are_requirements_met() || !$store->is_ready() || !$store->is_supported_mode($definition->get_mode())) {
return false;
}
// We always create a clone of the original store.
View
3 cache/classes/helper.php
@@ -455,8 +455,9 @@ public static function purge_store($storename) {
$class = $store['class'];
// Found the store: is it ready?
+ /* @var cache_store $instance */
$instance = new $class($store['name'], $store['configuration']);
- if (!$instance->is_ready()) {
+ if (!$instance::are_requirements_met() || !$instance->is_ready()) {
unset($instance);
return false;
}

0 comments on commit e9576ab

Please sign in to comment.
Something went wrong with that request. Please try again.