fixes FileLog doesn't delete on rotation if count(files) is greater 'rotate'

This commit is contained in:
Schlaefer 2013-10-06 13:59:52 +02:00
parent 355e2efbc6
commit 83d340a3af
2 changed files with 3 additions and 1 deletions

View file

@ -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));
} }
} }

View file

@ -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');