From 758dbdf8949c8b9971eb5e19506d42553a043836 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Mon, 12 Nov 2012 10:36:53 +1300 Subject: [PATCH] MDL-36111 cache: Fixed up typo's and trivial issues --- cache/classes/definition.php | 6 +++--- cache/classes/dummystore.php | 2 +- cache/classes/interfaces.php | 14 +++++++------- cache/classes/loaders.php | 4 ++-- cache/locallib.php | 2 +- cache/stores/file/lib.php | 16 +++++++++++----- cache/stores/memcache/lib.php | 2 +- cache/stores/memcached/lib.php | 2 +- cache/stores/mongodb/lib.php | 2 +- cache/stores/session/lib.php | 2 +- cache/stores/static/lib.php | 2 +- 11 files changed, 30 insertions(+), 24 deletions(-) diff --git a/cache/classes/definition.php b/cache/classes/definition.php index d02e082a768..fd93324069b 100644 --- a/cache/classes/definition.php +++ b/cache/classes/definition.php @@ -290,10 +290,10 @@ class cache_definition { throw new coding_exception('You must provide a mode when creating a cache definition'); } if (!array_key_exists('component', $definition)) { - throw new coding_exception('You must provide a mode when creating a cache definition'); + throw new coding_exception('You must provide a component when creating a cache definition'); } if (!array_key_exists('area', $definition)) { - throw new coding_exception('You must provide a mode when creating a cache definition'); + throw new coding_exception('You must provide an area when creating a cache definition'); } $mode = (int)$definition['mode']; $component = (string)$definition['component']; @@ -638,7 +638,7 @@ class cache_definition { */ public function get_data_source() { if (!$this->has_data_source()) { - throw new coding_exception('This cache does not use a datasource.'); + throw new coding_exception('This cache does not use a data source.'); } return forward_static_call(array($this->datasource, 'get_instance_for_cache'), $this); } diff --git a/cache/classes/dummystore.php b/cache/classes/dummystore.php index 870d960e542..4888f607001 100644 --- a/cache/classes/dummystore.php +++ b/cache/classes/dummystore.php @@ -147,7 +147,7 @@ class cachestore_dummy implements cache_store { * Returns true if this store supports multiple identifiers. * @return bool */ - public function supports_multiple_indentifiers() { + public function supports_multiple_identifiers() { return false; } diff --git a/cache/classes/interfaces.php b/cache/classes/interfaces.php index 1f96fa0c568..983bc6bd437 100644 --- a/cache/classes/interfaces.php +++ b/cache/classes/interfaces.php @@ -194,8 +194,8 @@ interface cache_loader_with_locking { * * Please note that this happens automatically if the cache definition requires locking. * it is still made a public method so that adhoc caches can use it if they choose. - * However this doesn't guarantee consistent access. It will become the reponsiblity of the calling code to ensure locks - * are acquired, checked, and released. + * However this doesn't guarantee consistent access. It will become the responsibility of the calling code to ensure + * locks are acquired, checked, and released. * * @param string|int $key * @return bool True if the lock could be acquired, false otherwise. @@ -207,8 +207,8 @@ interface cache_loader_with_locking { * * Please note that this happens automatically if the cache definition requires locking. * it is still made a public method so that adhoc caches can use it if they choose. - * However this doesn't guarantee consistent access. It will become the reponsiblity of the calling code to ensure locks - * are acquired, checked, and released. + * However this doesn't guarantee consistent access. It will become the responsibility of the calling code to ensure + * locks are acquired, checked, and released. * * @param string|int $key * @return bool True if this code has the lock, false if there is a lock but this code doesn't have it, @@ -221,8 +221,8 @@ interface cache_loader_with_locking { * * Please note that this happens automatically if the cache definition requires locking. * it is still made a public method so that adhoc caches can use it if they choose. - * However this doesn't guarantee consistent access. It will become the reponsiblity of the calling code to ensure locks - * are acquired, checked, and released. + * However this doesn't guarantee consistent access. It will become the responsibility of the calling code to ensure + * locks are acquired, checked, and released. * * @param string|int $key * @return bool True if the lock has been released, false if there was a problem releasing the lock. @@ -314,7 +314,7 @@ interface cache_store { * * @return bool */ - public function supports_multiple_indentifiers(); + public function supports_multiple_identifiers(); /** * Returns true if this cache store instance promotes data guarantee. diff --git a/cache/classes/loaders.php b/cache/classes/loaders.php index d0b3a4de1e5..c837cd8bc8c 100644 --- a/cache/classes/loaders.php +++ b/cache/classes/loaders.php @@ -18,7 +18,7 @@ * Cache loaders * * This file is part of Moodle's cache API, affectionately called MUC. - * It contains the components that are requried in order to use caching. + * It contains the components that are required in order to use caching. * * @package core * @category cache @@ -795,7 +795,7 @@ class cache implements cache_loader { */ protected function parse_key($key) { // First up if the store supports multiple keys we'll go with that. - if ($this->store->supports_multiple_indentifiers()) { + if ($this->store->supports_multiple_identifiers()) { $result = $this->definition->generate_multi_key_parts(); $result['key'] = $key; return $result; diff --git a/cache/locallib.php b/cache/locallib.php index fc927e0d39f..e8e43a3d454 100644 --- a/cache/locallib.php +++ b/cache/locallib.php @@ -518,7 +518,7 @@ abstract class cache_administration_helper extends cache_helper { ($store->get_supported_modes($return) & cache_store::MODE_REQUEST) == cache_store::MODE_REQUEST, ), 'supports' => array( - 'multipleidentifiers' => $store->supports_multiple_indentifiers(), + 'multipleidentifiers' => $store->supports_multiple_identifiers(), 'dataguarantee' => $store->supports_data_guarantee(), 'nativettl' => $store->supports_native_ttl(), 'nativelocking' => ($store instanceof cache_is_lockable), diff --git a/cache/stores/file/lib.php b/cache/stores/file/lib.php index 0aa3f48ce94..0a18b3a636f 100644 --- a/cache/stores/file/lib.php +++ b/cache/stores/file/lib.php @@ -209,7 +209,7 @@ class cachestore_file implements cache_store, cache_is_key_aware { * * @return bool */ - public function supports_multiple_indentifiers() { + public function supports_multiple_identifiers() { return false; } @@ -255,8 +255,11 @@ class cachestore_file implements cache_store, cache_is_key_aware { * Pre-scan the cache to see which keys are present. */ protected function prescan_keys() { - foreach (glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT) as $filename) { - $this->keys[basename($filename)] = filemtime($filename); + $files = glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT); + if (is_array($files)) { + foreach ($files as $filename) { + $this->keys[basename($filename)] = filemtime($filename); + } } } @@ -510,8 +513,11 @@ class cachestore_file implements cache_store, cache_is_key_aware { * @return boolean True on success. False otherwise. */ public function purge() { - foreach (glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT) as $filename) { - @unlink($filename); + $files = glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT); + if (is_array($files)) { + foreach ($files as $filename) { + @unlink($filename); + } } $this->keys = array(); return true; diff --git a/cache/stores/memcache/lib.php b/cache/stores/memcache/lib.php index d684403db33..d62fac7bd3e 100644 --- a/cache/stores/memcache/lib.php +++ b/cache/stores/memcache/lib.php @@ -178,7 +178,7 @@ class cachestore_memcache implements cache_store { * * @return bool */ - public function supports_multiple_indentifiers() { + public function supports_multiple_identifiers() { return false; } diff --git a/cache/stores/memcached/lib.php b/cache/stores/memcached/lib.php index 527a5cae19d..419e640c8c7 100644 --- a/cache/stores/memcached/lib.php +++ b/cache/stores/memcached/lib.php @@ -204,7 +204,7 @@ class cachestore_memcached implements cache_store { * * @return bool */ - public function supports_multiple_indentifiers() { + public function supports_multiple_identifiers() { return false; } diff --git a/cache/stores/mongodb/lib.php b/cache/stores/mongodb/lib.php index 4bd4229130e..2427d92ffa3 100644 --- a/cache/stores/mongodb/lib.php +++ b/cache/stores/mongodb/lib.php @@ -230,7 +230,7 @@ class cachestore_mongodb implements cache_store { * Returns true if this store is making use of multiple identifiers. * @return bool */ - public function supports_multiple_indentifiers() { + public function supports_multiple_identifiers() { return $this->extendedmode; } diff --git a/cache/stores/session/lib.php b/cache/stores/session/lib.php index bd9d0a0b5e7..ba82c17c46b 100644 --- a/cache/stores/session/lib.php +++ b/cache/stores/session/lib.php @@ -127,7 +127,7 @@ class cachestore_session extends session_data_store implements cache_store, cach * * @return bool */ - public function supports_multiple_indentifiers() { + public function supports_multiple_identifiers() { return false; } diff --git a/cache/stores/static/lib.php b/cache/stores/static/lib.php index 8e0f41cc636..eae6c0055de 100644 --- a/cache/stores/static/lib.php +++ b/cache/stores/static/lib.php @@ -127,7 +127,7 @@ class cachestore_static extends static_data_store implements cache_store, cache_ * * @return bool */ - public function supports_multiple_indentifiers() { + public function supports_multiple_identifiers() { return false; }