diff options
Diffstat (limited to 'libs/Zend/Cache/Backend.php')
-rw-r--r-- | libs/Zend/Cache/Backend.php | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/libs/Zend/Cache/Backend.php b/libs/Zend/Cache/Backend.php index f71dae135a..052181972f 100644 --- a/libs/Zend/Cache/Backend.php +++ b/libs/Zend/Cache/Backend.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Backend.php 20882 2010-02-03 18:19:44Z matthew $ + * @version $Id: Backend.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend @@ -140,77 +140,77 @@ class Zend_Cache_Backend { return true; } - + /** * Determine system TMP directory and detect if we have read access * - * inspired from Zend_File_Transfer_Adapter_Abstract + * inspired from Zend_File_Transfer_Adapter_Abstract * * @return string * @throws Zend_Cache_Exception if unable to determine directory */ public function getTmpDir() { - $tmpdir = array(); + $tmpdir = array(); foreach (array($_ENV, $_SERVER) as $tab) { - foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) { - if (isset($tab[$key])) { - if (($key == 'windir') or ($key == 'SystemRoot')) { + foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) { + if (isset($tab[$key])) { + if (($key == 'windir') or ($key == 'SystemRoot')) { $dir = realpath($tab[$key] . '\\temp'); } else { - $dir = realpath($tab[$key]); - } - if ($this->_isGoodTmpDir($dir)) { - return $dir; + $dir = realpath($tab[$key]); } - } - } + if ($this->_isGoodTmpDir($dir)) { + return $dir; + } + } + } } $upload = ini_get('upload_tmp_dir'); if ($upload) { $dir = realpath($upload); - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } + if ($this->_isGoodTmpDir($dir)) { + return $dir; + } } if (function_exists('sys_get_temp_dir')) { $dir = sys_get_temp_dir(); - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } + if ($this->_isGoodTmpDir($dir)) { + return $dir; + } } // Attemp to detect by creating a temporary file $tempFile = tempnam(md5(uniqid(rand(), TRUE)), ''); if ($tempFile) { - $dir = realpath(dirname($tempFile)); + $dir = realpath(dirname($tempFile)); unlink($tempFile); if ($this->_isGoodTmpDir($dir)) { return $dir; } } if ($this->_isGoodTmpDir('/tmp')) { - return '/tmp'; + return '/tmp'; } if ($this->_isGoodTmpDir('\\temp')) { - return '\\temp'; + return '\\temp'; } Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually'); } - + /** * Verify if the given temporary directory is readable and writable - * + * * @param $dir temporary directory * @return boolean true if the directory is ok */ protected function _isGoodTmpDir($dir) { - if (is_readable($dir)) { - if (is_writable($dir)) { - return true; - } - } - return false; + if (is_readable($dir)) { + if (is_writable($dir)) { + return true; + } + } + return false; } /** @@ -226,17 +226,23 @@ class Zend_Cache_Backend if (!isset($this->_directives['logging']) || !$this->_directives['logging']) { return; } - + try { + /** + * @see Zend_Log + */ + require_once 'Zend/Log.php'; + } catch (Zend_Exception $e) { + Zend_Cache::throwException('Logging feature is enabled but the Zend_Log class is not available'); + } if (isset($this->_directives['logger'])) { if ($this->_directives['logger'] instanceof Zend_Log) { return; + } else { + Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.'); } - Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.'); } - // Create a default logger to the standard output stream - // require_once 'Zend/Log.php'; - // require_once 'Zend/Log/Writer/Stream.php'; + require_once 'Zend/Log/Writer/Stream.php'; $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output')); $this->_directives['logger'] = $logger; } @@ -255,7 +261,7 @@ class Zend_Cache_Backend } if (!isset($this->_directives['logger'])) { - Zend_Cache::throwException('Logging is enabled but logger is not set.'); + Zend_Cache::throwException('Logging is enabled but logger is not set.'); } $logger = $this->_directives['logger']; if (!$logger instanceof Zend_Log) { |