mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-43349 cache: init now checks store requirements are met
This commit is contained in:
parent
14d1f4e42e
commit
87f62d8e09
2 changed files with 10 additions and 3 deletions
10
cache/classes/factory.php
vendored
10
cache/classes/factory.php
vendored
|
@ -236,6 +236,11 @@ class cache_factory {
|
||||||
public function create_cache(cache_definition $definition) {
|
public function create_cache(cache_definition $definition) {
|
||||||
$class = $definition->get_cache_class();
|
$class = $definition->get_cache_class();
|
||||||
$stores = cache_helper::get_stores_suitable_for_definition($definition);
|
$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) {
|
if (count($stores) === 0) {
|
||||||
// Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser.
|
// 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);
|
$stores[] = $this->create_dummy_store($definition);
|
||||||
|
@ -253,7 +258,7 @@ class cache_factory {
|
||||||
/**
|
/**
|
||||||
* Creates a store instance given its name and configuration.
|
* 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 string $name The name of the store (must be unique remember)
|
||||||
* @param array $details
|
* @param array $details
|
||||||
|
@ -267,8 +272,9 @@ class cache_factory {
|
||||||
$store = new $class($details['name'], $details['configuration']);
|
$store = new $class($details['name'], $details['configuration']);
|
||||||
$this->stores[$name] = $store;
|
$this->stores[$name] = $store;
|
||||||
}
|
}
|
||||||
|
/* @var cache_store $store */
|
||||||
$store = $this->stores[$name];
|
$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;
|
return false;
|
||||||
}
|
}
|
||||||
// We always create a clone of the original store.
|
// We always create a clone of the original store.
|
||||||
|
|
3
cache/classes/helper.php
vendored
3
cache/classes/helper.php
vendored
|
@ -455,8 +455,9 @@ class cache_helper {
|
||||||
$class = $store['class'];
|
$class = $store['class'];
|
||||||
|
|
||||||
// Found the store: is it ready?
|
// Found the store: is it ready?
|
||||||
|
/* @var cache_store $instance */
|
||||||
$instance = new $class($store['name'], $store['configuration']);
|
$instance = new $class($store['name'], $store['configuration']);
|
||||||
if (!$instance->is_ready()) {
|
if (!$instance::are_requirements_met() || !$instance->is_ready()) {
|
||||||
unset($instance);
|
unset($instance);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue