import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -105,10 +105,9 @@ class Zend_Cache_Backend
Zend_Cache::throwException("Incorrect option name : $name");
}
$name = strtolower($name);
if (!array_key_exists($name, $this->_options)) {
Zend_Cache::throwException("Incorrect option name : $name");
if (array_key_exists($name, $this->_options)) {
$this->_options[$name] = $value;
}
$this->_options[$name] = $value;
}
/**
@ -132,42 +131,85 @@ class Zend_Cache_Backend
* Return true if the automatic cleaning is available for the backend
*
* DEPRECATED : use getCapabilities() instead
*
* @deprecated
*
* @deprecated
* @return boolean
*/
public function isAutomaticCleaningAvailable()
{
return true;
}
/**
* Return a system-wide tmp directory
* Determine system TMP directory and detect if we have read access
*
* @return string System-wide tmp directory
* inspired from Zend_File_Transfer_Adapter_Abstract
*
* @return string
* @throws Zend_Cache_Exception if unable to determine directory
*/
static function getTmpDir()
public function getTmpDir()
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// windows...
foreach (array($_ENV, $_SERVER) as $tab) {
foreach (array('TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
if (isset($tab[$key])) {
$result = $tab[$key];
if (($key == 'windir') or ($key == 'SystemRoot')) {
$result = $result . '\\temp';
}
return $result;
$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')) {
$dir = realpath($tab[$key] . '\\temp');
} else {
$dir = realpath($tab[$key]);
}
}
}
return '\\temp';
} else {
// unix...
if (isset($_ENV['TMPDIR'])) return $_ENV['TMPDIR'];
if (isset($_SERVER['TMPDIR'])) return $_SERVER['TMPDIR'];
return '/tmp';
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
}
}
$upload = ini_get('upload_tmp_dir');
if ($upload) {
$dir = realpath($upload);
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
if (function_exists('sys_get_temp_dir')) {
$dir = sys_get_temp_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));
unlink($tempFile);
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
if ($this->_isGoodTmpDir('/tmp')) {
return '/tmp';
}
if ($this->_isGoodTmpDir('\\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;
}
/**
@ -191,8 +233,12 @@ class Zend_Cache_Backend
} catch (Zend_Exception $e) {
Zend_Cache::throwException('Logging feature is enabled but the Zend_Log class is not available');
}
if (isset($this->_directives['logger']) && $this->_directives['logger'] instanceof Zend_Log) {
return;
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.');
}
}
// Create a default logger to the standard output stream
require_once 'Zend/Log/Writer/Stream.php';
@ -212,11 +258,14 @@ class Zend_Cache_Backend
if (!$this->_directives['logging']) {
return;
}
if (!(isset($this->_directives['logger']) || $this->_directives['logger'] instanceof Zend_Log)) {
Zend_Cache::throwException('Logging is enabled but logger is not set');
if (!isset($this->_directives['logger'])) {
Zend_Cache::throwException('Logging is enabled but logger is not set.');
}
$logger = $this->_directives['logger'];
if (!$logger instanceof Zend_Log) {
Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
}
$logger->log($message, $priority);
}
}