mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix: write() after clearGroup() does not actually write to file
Although clearGroup() does not use $this->_File, it needs to be null-ed so that subsequent write() call do not see stale object.
This commit is contained in:
parent
3c036e9ebf
commit
03e5207aa1
2 changed files with 27 additions and 0 deletions
|
@ -369,6 +369,7 @@ class FileEngine extends CacheEngine {
|
|||
unlink($object->getPathName());
|
||||
}
|
||||
}
|
||||
$this->_File = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -411,6 +411,32 @@ class FileEngineTest extends CakeTestCase {
|
|||
$this->assertTrue(Cache::write('test_groups3', 'value3', 'file_groups'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that clearing with repeat writes works properly
|
||||
*/
|
||||
public function testClearingWithRepeatWrites() {
|
||||
Cache::config('repeat', array(
|
||||
'engine' => 'File', 'groups' => array('users')
|
||||
));
|
||||
|
||||
$this->assertTrue(Cache::write('user', 'rchavik', 'repeat'));
|
||||
$this->assertEquals('rchavik', Cache::read('user', 'repeat'));
|
||||
|
||||
Cache::delete('user', 'repeat');
|
||||
$this->assertEquals(false, Cache::read('user', 'repeat'));
|
||||
|
||||
$this->assertTrue(Cache::write('user', 'ADmad', 'repeat'));
|
||||
$this->assertEquals('ADmad', Cache::read('user', 'repeat'));
|
||||
|
||||
Cache::clearGroup('users', 'repeat');
|
||||
$this->assertEquals(false, Cache::read('user', 'repeat'));
|
||||
|
||||
$this->assertTrue(Cache::write('user', 'markstory', 'repeat'));
|
||||
$this->assertEquals('markstory', Cache::read('user', 'repeat'));
|
||||
|
||||
Cache::drop('repeat');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that deleting from a groups-enabled config is possible
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue