mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
fixes FileLog doesn't delete on rotation if count(files) is greater 'rotate'
This commit is contained in:
parent
355e2efbc6
commit
83d340a3af
2 changed files with 3 additions and 1 deletions
|
@ -206,7 +206,7 @@ class FileLog extends BaseLog {
|
||||||
|
|
||||||
if ($this->_config['rotate']) {
|
if ($this->_config['rotate']) {
|
||||||
$files = glob($filepath . '.*');
|
$files = glob($filepath . '.*');
|
||||||
if (count($files) === $this->_config['rotate']) {
|
while (count($files) >= $this->_config['rotate']) {
|
||||||
unlink(array_shift($files));
|
unlink(array_shift($files));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,8 @@ class FileLogTest extends CakeTestCase {
|
||||||
$result = file_get_contents($files[1]);
|
$result = file_get_contents($files[1]);
|
||||||
$this->assertRegExp('/Warning: Test warning second/', $result);
|
$this->assertRegExp('/Warning: Test warning second/', $result);
|
||||||
|
|
||||||
|
file_put_contents($path . 'error.log.0000000000', "The oldest log file with over 35 bytes.\n");
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
$log->write('warning', 'Test warning fourth');
|
$log->write('warning', 'Test warning fourth');
|
||||||
|
|
Loading…
Reference in a new issue