From a5581c7376bfed054e98aa9e713d0da27204660b Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Mon, 6 Jan 2014 14:47:12 +0800 Subject: [PATCH] Revert "MDL-43349 cache: is_ready now checks are_requirements_met by default" This reverts commit 2201c02d73ff2998b5019ab1173349ebbee7a5e6. --- cache/classes/dummystore.php | 8 ++++++++ cache/classes/factory.php | 2 +- cache/classes/helper.php | 2 +- cache/classes/store.php | 4 +--- cache/stores/session/lib.php | 8 ++++++++ cache/stores/static/lib.php | 8 ++++++++ cache/upgrade.txt | 3 --- 7 files changed, 27 insertions(+), 8 deletions(-) diff --git a/cache/classes/dummystore.php b/cache/classes/dummystore.php index 14eecd8e8cf..55ee3add584 100644 --- a/cache/classes/dummystore.php +++ b/cache/classes/dummystore.php @@ -129,6 +129,14 @@ class cachestore_dummy extends cache_store { return (!empty($this->definition)); } + /** + * Returns true if this is ready. + * @return bool + */ + public function is_ready() { + return true; + } + /** * Returns true the given mode is supported. * @param int $mode diff --git a/cache/classes/factory.php b/cache/classes/factory.php index 2a9621cd63c..954267ea660 100644 --- a/cache/classes/factory.php +++ b/cache/classes/factory.php @@ -274,7 +274,7 @@ class cache_factory { } /* @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. diff --git a/cache/classes/helper.php b/cache/classes/helper.php index c21ac47704b..96bedb2bb59 100644 --- a/cache/classes/helper.php +++ b/cache/classes/helper.php @@ -470,7 +470,7 @@ class cache_helper { // 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; } diff --git a/cache/classes/store.php b/cache/classes/store.php index 18fb963e7ca..d757157536c 100644 --- a/cache/classes/store.php +++ b/cache/classes/store.php @@ -179,9 +179,7 @@ abstract class cache_store implements cache_store_interface { * Returns true if this cache store instance is ready to use. * @return bool */ - public function is_ready() { - return self::are_requirements_met(); - } + abstract public function is_ready(); /** * Retrieves an item from the cache store given its key. diff --git a/cache/stores/session/lib.php b/cache/stores/session/lib.php index d320b8c1088..d5e245ebe23 100644 --- a/cache/stores/session/lib.php +++ b/cache/stores/session/lib.php @@ -222,6 +222,14 @@ class cachestore_session extends session_data_store implements cache_is_key_awar return (is_array($this->store)); } + /** + * Returns true if this store instance is ready to be used. + * @return bool + */ + public function is_ready() { + return true; + } + /** * Retrieves an item from the cache store given its key. * diff --git a/cache/stores/static/lib.php b/cache/stores/static/lib.php index 5f7de851d71..e54ee838466 100644 --- a/cache/stores/static/lib.php +++ b/cache/stores/static/lib.php @@ -217,6 +217,14 @@ class cachestore_static extends static_data_store implements cache_is_key_aware, return (is_array($this->store)); } + /** + * Returns true if this store instance is ready to be used. + * @return bool + */ + public function is_ready() { + return true; + } + /** * Retrieves an item from the cache store given its key. * diff --git a/cache/upgrade.txt b/cache/upgrade.txt index 75ce1e69eb5..38f9c4b21bc 100644 --- a/cache/upgrade.txt +++ b/cache/upgrade.txt @@ -1,9 +1,6 @@ This files describes API changes in /cache/stores/* - cache store plugins. Information provided here is intended especially for developers. -=== 2.7 === -* cache_store::is_ready is no longer abstract, calling cache_store::are_requirements_met by default. - === 2.6 === * All cache instances are recorded and subsequent requests are given a reference to the original instance. * The persistent option for the cache definition has been deprecated. Please use the staticacceleration option instead. -- 2.43.0