equal
deleted
inserted
replaced
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Cache |
16 * @package Zend_Cache |
17 * @subpackage Zend_Cache_Backend |
17 * @subpackage Zend_Cache_Backend |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Static.php 24989 2012-06-21 07:24:13Z mabe $ |
20 * @version $Id$ |
21 */ |
21 */ |
22 |
22 |
23 /** |
23 /** |
24 * @see Zend_Cache_Backend_Interface |
24 * @see Zend_Cache_Backend_Interface |
25 */ |
25 */ |
31 require_once 'Zend/Cache/Backend.php'; |
31 require_once 'Zend/Cache/Backend.php'; |
32 |
32 |
33 /** |
33 /** |
34 * @package Zend_Cache |
34 * @package Zend_Cache |
35 * @subpackage Zend_Cache_Backend |
35 * @subpackage Zend_Cache_Backend |
36 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
36 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
37 * @license http://framework.zend.com/license/new-bsd New BSD License |
37 * @license http://framework.zend.com/license/new-bsd New BSD License |
38 */ |
38 */ |
39 class Zend_Cache_Backend_Static |
39 class Zend_Cache_Backend_Static |
40 extends Zend_Cache_Backend |
40 extends Zend_Cache_Backend |
41 implements Zend_Cache_Backend_Interface |
41 implements Zend_Cache_Backend_Interface |
45 /** |
45 /** |
46 * Static backend options |
46 * Static backend options |
47 * @var array |
47 * @var array |
48 */ |
48 */ |
49 protected $_options = array( |
49 protected $_options = array( |
50 'public_dir' => null, |
50 'public_dir' => null, |
51 'sub_dir' => 'html', |
51 'sub_dir' => 'html', |
52 'file_extension' => '.html', |
52 'file_extension' => '.html', |
53 'index_filename' => 'index', |
53 'index_filename' => 'index', |
54 'file_locking' => true, |
54 'file_locking' => true, |
55 'cache_file_umask' => 0600, |
55 'cache_file_perm' => 0600, |
56 'cache_directory_umask' => 0700, |
56 'cache_directory_perm' => 0700, |
57 'debug_header' => false, |
57 'debug_header' => false, |
58 'tag_cache' => null, |
58 'tag_cache' => null, |
59 'disable_caching' => false |
59 'disable_caching' => false |
60 ); |
60 ); |
61 |
61 |
62 /** |
62 /** |
63 * Cache for handling tags |
63 * Cache for handling tags |
64 * @var Zend_Cache_Core |
64 * @var Zend_Cache_Core |
83 public function setOption($name, $value) |
83 public function setOption($name, $value) |
84 { |
84 { |
85 if ($name == 'tag_cache') { |
85 if ($name == 'tag_cache') { |
86 $this->setInnerCache($value); |
86 $this->setInnerCache($value); |
87 } else { |
87 } else { |
|
88 // See #ZF-12047 and #GH-91 |
|
89 if ($name == 'cache_file_umask') { |
|
90 trigger_error( |
|
91 "'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", |
|
92 E_USER_NOTICE |
|
93 ); |
|
94 |
|
95 $name = 'cache_file_perm'; |
|
96 } |
|
97 if ($name == 'cache_directory_umask') { |
|
98 trigger_error( |
|
99 "'cache_directory_umask' is deprecated -> please use 'cache_directory_perm' instead", |
|
100 E_USER_NOTICE |
|
101 ); |
|
102 |
|
103 $name = 'cache_directory_perm'; |
|
104 } |
|
105 |
88 parent::setOption($name, $value); |
106 parent::setOption($name, $value); |
89 } |
107 } |
90 return $this; |
108 return $this; |
91 } |
109 } |
92 |
110 |
231 if ($this->_options['file_locking']) { |
249 if ($this->_options['file_locking']) { |
232 $result = file_put_contents($file, $data, LOCK_EX); |
250 $result = file_put_contents($file, $data, LOCK_EX); |
233 } else { |
251 } else { |
234 $result = file_put_contents($file, $data); |
252 $result = file_put_contents($file, $data); |
235 } |
253 } |
236 @chmod($file, $this->_octdec($this->_options['cache_file_umask'])); |
254 @chmod($file, $this->_octdec($this->_options['cache_file_perm'])); |
237 |
255 |
238 if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { |
256 if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { |
239 $this->_tagged = $tagged; |
257 $this->_tagged = $tagged; |
240 } elseif ($this->_tagged === null) { |
258 } elseif ($this->_tagged === null) { |
241 $this->_tagged = array(); |
259 $this->_tagged = array(); |
257 */ |
275 */ |
258 protected function _createDirectoriesFor($path) |
276 protected function _createDirectoriesFor($path) |
259 { |
277 { |
260 if (!is_dir($path)) { |
278 if (!is_dir($path)) { |
261 $oldUmask = umask(0); |
279 $oldUmask = umask(0); |
262 if ( !@mkdir($path, $this->_octdec($this->_options['cache_directory_umask']), true)) { |
280 if ( !@mkdir($path, $this->_octdec($this->_options['cache_directory_perm']), true)) { |
263 $lastErr = error_get_last(); |
281 $lastErr = error_get_last(); |
264 umask($oldUmask); |
282 umask($oldUmask); |
265 Zend_Cache::throwException("Can't create directory: {$lastErr['message']}"); |
283 Zend_Cache::throwException("Can't create directory: {$lastErr['message']}"); |
266 } |
284 } |
267 umask($oldUmask); |
285 umask($oldUmask); |
373 * ($tags can be an array of strings or a single string) |
391 * ($tags can be an array of strings or a single string) |
374 * |
392 * |
375 * @param string $mode Clean mode |
393 * @param string $mode Clean mode |
376 * @param array $tags Array of tags |
394 * @param array $tags Array of tags |
377 * @return boolean true if no problem |
395 * @return boolean true if no problem |
|
396 * @throws Zend_Exception |
378 */ |
397 */ |
379 public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) |
398 public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) |
380 { |
399 { |
381 $result = false; |
400 $result = false; |
382 switch ($mode) { |
401 switch ($mode) { |