From 0688ac9ad88a03f1c56cfcd9e3c475b83301344d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 20 Apr 2012 10:25:04 -0400 Subject: Start comment cleanup of libraries --- system/libraries/Cache/Cache.php | 48 +++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'system/libraries/Cache/Cache.php') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index f98241617..409323def 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -36,16 +36,38 @@ */ class CI_Cache extends CI_Driver_Library { - protected $valid_drivers = array( - 'cache_apc', - 'cache_file', - 'cache_memcached', - 'cache_dummy', - 'cache_wincache' - ); - - protected $_cache_path = NULL; // Path of cache files (if file-based cache) - protected $_adapter = 'dummy'; + /** + * Valid cache drivers + * + * @var array + */ + protected $valid_drivers = array( + 'cache_apc', + 'cache_file', + 'cache_memcached', + 'cache_dummy', + 'cache_wincache' + ); + + /** + * Path of cache files (if file-based cache) + * + * @var string + */ + protected $_cache_path = NULL; + + /** + * Reference to the driver + * + * @var mixe + */ + protected $_adapter = 'dummy'; + + /** + * Fallback driver + * + * @param string + */ protected $_backup_driver; /** @@ -59,9 +81,9 @@ class CI_Cache extends CI_Driver_Library { public function __construct($config = array()) { $default_config = array( - 'adapter', - 'memcached' - ); + 'adapter', + 'memcached' + ); foreach ($default_config as $key) { -- cgit v1.2.3-24-g4f1b From b82bc3a016ce01dfeb993da5918853625a40af86 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 09:12:58 -0400 Subject: Fix Cache, Image_lib and Log libraries --- system/libraries/Cache/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Cache/Cache.php') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 409323def..0493d5a6e 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -59,7 +59,7 @@ class CI_Cache extends CI_Driver_Library { /** * Reference to the driver * - * @var mixe + * @var mixed */ protected $_adapter = 'dummy'; -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Cache/Cache.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Cache/Cache.php') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 0493d5a6e..ba732ee8e 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -55,14 +55,14 @@ class CI_Cache extends CI_Driver_Library { * @var string */ protected $_cache_path = NULL; - + /** * Reference to the driver * * @var mixed */ protected $_adapter = 'dummy'; - + /** * Fallback driver * -- cgit v1.2.3-24-g4f1b From bf50a3b15c70441a72ec3012319cd63425ba4d20 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Sun, 27 May 2012 19:04:43 -0500 Subject: Fix issue where cache backup is ignored on first call. --- system/libraries/Cache/Cache.php | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'system/libraries/Cache/Cache.php') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index ba732ee8e..53f9f81a7 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -68,7 +68,7 @@ class CI_Cache extends CI_Driver_Library { * * @param string */ - protected $_backup_driver; + protected $_backup_driver = 'dummy'; /** * Constructor @@ -102,6 +102,22 @@ class CI_Cache extends CI_Driver_Library { $this->_backup_driver = $config['backup']; } } + + // If the specified adapter isn't available, check the backup. + if ( ! $this->is_supported($this->_adapter)) + { + if ( ! $this->is_supported($this->_backup_driver)) + { + // Backup isn't supported either. Default to 'Dummy' driver. + log_message('error', 'Cache adapter "'.$this->_adapter.'" and backup "'.$this->_backup_driver.'" are both unavailable. Cache is now using "Dummy" adapter.'); + $this->_adapter = 'dummy'; + } + else + { + // Backup is supported. Set it to primary. + $this->_adapter = $this->_backup_driver; + } + } } // ------------------------------------------------------------------------ @@ -206,26 +222,6 @@ class CI_Cache extends CI_Driver_Library { return $support[$driver]; } - // ------------------------------------------------------------------------ - - /** - * __get() - * - * @param child - * @return object - */ - public function __get($child) - { - $obj = parent::__get($child); - - if ( ! $this->is_supported($child)) - { - $this->_adapter = $this->_backup_driver; - } - - return $obj; - } - } /* End of file Cache.php */ -- cgit v1.2.3-24-g4f1b