diff --git a/lib/Cake/Log/Engine/FileLog.php b/lib/Cake/Log/Engine/FileLog.php index 071f12f8d..22c1a9992 100644 --- a/lib/Cake/Log/Engine/FileLog.php +++ b/lib/Cake/Log/Engine/FileLog.php @@ -206,7 +206,7 @@ class FileLog extends BaseLog { if ($this->_config['rotate']) { $files = glob($filepath . '.*'); - if (count($files) === $this->_config['rotate']) { + while (count($files) >= $this->_config['rotate']) { unlink(array_shift($files)); } } diff --git a/lib/Cake/Test/Case/Log/Engine/FileLogTest.php b/lib/Cake/Test/Case/Log/Engine/FileLogTest.php index 825adb9f0..4eba6cfad 100644 --- a/lib/Cake/Test/Case/Log/Engine/FileLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/FileLogTest.php @@ -117,6 +117,8 @@ class FileLogTest extends CakeTestCase { $result = file_get_contents($files[1]); $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); clearstatcache(); $log->write('warning', 'Test warning fourth');