mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Making locking file caching the default.
Locking files prevents many issues with unserialize() warnings caused by partially written files. Fix a locking issue where files would be left locked. Fixes #1988
This commit is contained in:
parent
b1dad6e5bd
commit
79687a2dcf
2 changed files with 5 additions and 2 deletions
|
@ -66,7 +66,7 @@ class FileEngine extends CacheEngine {
|
|||
public function init($settings = array()) {
|
||||
parent::init(array_merge(
|
||||
array(
|
||||
'engine' => 'File', 'path' => CACHE, 'prefix'=> 'cake_', 'lock'=> false,
|
||||
'engine' => 'File', 'path' => CACHE, 'prefix'=> 'cake_', 'lock'=> true,
|
||||
'serialize'=> true, 'isWindows' => false
|
||||
),
|
||||
$settings
|
||||
|
@ -162,6 +162,9 @@ class FileEngine extends CacheEngine {
|
|||
$cachetime = intval($this->_File->current());
|
||||
|
||||
if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
|
||||
if ($this->settings['lock']) {
|
||||
$this->_File->flock(LOCK_UN);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ class CacheTest extends CakeTestCase {
|
|||
$expected = array(
|
||||
'path' => TMP . 'sessions' . DS,
|
||||
'prefix' => 'cake_',
|
||||
'lock' => false,
|
||||
'lock' => true,
|
||||
'serialize' => true,
|
||||
'duration' => 3600,
|
||||
'probability' => 100,
|
||||
|
|
Loading…
Reference in a new issue