diff options
author | Eric Roberts <eric@cryode.com> | 2012-05-28 02:04:43 +0200 |
---|---|---|
committer | Eric Roberts <eric@cryode.com> | 2012-05-28 02:04:43 +0200 |
commit | bf50a3b15c70441a72ec3012319cd63425ba4d20 (patch) | |
tree | 33220ecba3f67a1b64c402b20c2902eb28c3f69f /system | |
parent | 11fd4b8759438f216318e3e1e004f918b88a56ad (diff) |
Fix issue where cache backup is ignored on first call.
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Cache/Cache.php | 38 |
1 files changed, 17 insertions, 21 deletions
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 */ |