|
|
@@ -36,8 +36,8 @@ require_once 'Zend/Cache/Backend.php';
|
|
|
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
*/
|
|
|
-class Zend_Cache_Backend_Static
|
|
|
- extends Zend_Cache_Backend
|
|
|
+class Zend_Cache_Backend_Static
|
|
|
+ extends Zend_Cache_Backend
|
|
|
implements Zend_Cache_Backend_Interface
|
|
|
{
|
|
|
const INNER_CACHE_NAME = 'zend_cache_backend_static_tagcache';
|
|
|
@@ -153,7 +153,7 @@ class Zend_Cache_Backend_Static
|
|
|
* Test if a cache is available or not (for the given id)
|
|
|
*
|
|
|
* @param string $id cache id
|
|
|
- * @return bool
|
|
|
+ * @return bool
|
|
|
*/
|
|
|
public function test($id)
|
|
|
{
|
|
|
@@ -172,7 +172,7 @@ class Zend_Cache_Backend_Static
|
|
|
return false;
|
|
|
}
|
|
|
$pathName = $this->_options['public_dir'] . dirname($id);
|
|
|
-
|
|
|
+
|
|
|
// Switch extension if needed
|
|
|
if (isset($this->_tagged[$id])) {
|
|
|
$extension = $this->_tagged[$id]['extension'];
|
|
|
@@ -255,12 +255,19 @@ class Zend_Cache_Backend_Static
|
|
|
$this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
|
|
|
return (bool) $result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Recursively create the directories needed to write the static file
|
|
|
*/
|
|
|
protected function _createDirectoriesFor($path)
|
|
|
{
|
|
|
+ if ( !is_dir($path)
|
|
|
+ && !@mkdir($path, $this->_options['cache_directory_umask'], true)) {
|
|
|
+ $lastErr = error_get_last();
|
|
|
+ Zend_Cache::throwException("Can't create directory: {$lastErr['message']}");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
$parts = explode('/', $path);
|
|
|
$directory = '';
|
|
|
foreach ($parts as $part) {
|
|
|
@@ -269,8 +276,9 @@ class Zend_Cache_Backend_Static
|
|
|
mkdir($directory, $this->_octdec($this->_options['cache_directory_umask']));
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Detect serialization of data (cannot predict since this is the only way
|
|
|
* to obey the interface yet pass in another parameter).
|
|
|
@@ -481,8 +489,8 @@ class Zend_Cache_Backend_Static
|
|
|
|
|
|
/**
|
|
|
* Verify path exists and is non-empty
|
|
|
- *
|
|
|
- * @param string $path
|
|
|
+ *
|
|
|
+ * @param string $path
|
|
|
* @return bool
|
|
|
*/
|
|
|
protected function _verifyPath($path)
|
|
|
@@ -494,7 +502,7 @@ class Zend_Cache_Backend_Static
|
|
|
|
|
|
/**
|
|
|
* Determine the page to save from the request
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
protected function _detectId()
|
|
|
@@ -525,14 +533,14 @@ class Zend_Cache_Backend_Static
|
|
|
|
|
|
// Validation assumes no query string, fragments or scheme included - only the path
|
|
|
if (!preg_match(
|
|
|
- '/^(?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*\'()\[\]:@&=+$,;])*)?)+$/',
|
|
|
+ '/^(?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*\'()\[\]:@&=+$,;])*)?)+$/',
|
|
|
$string
|
|
|
)
|
|
|
) {
|
|
|
Zend_Cache::throwException("Invalid id or tag '$string' : must be a valid URL path");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Detect an octal string and return its octal value for file permission ops
|
|
|
* otherwise return the non-string (assumed octal or decimal int already)
|
|
|
@@ -547,7 +555,7 @@ class Zend_Cache_Backend_Static
|
|
|
}
|
|
|
return $val;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Decode a request URI from the provided ID
|
|
|
*/
|