From 83d340a3afeae83065b59a257bf8b7ecfe24de74 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Sun, 6 Oct 2013 13:59:52 +0200 Subject: [PATCH] fixes FileLog doesn't delete on rotation if count(files) is greater 'rotate' --- lib/Cake/Log/Engine/FileLog.php | 2 +- lib/Cake/Test/Case/Log/Engine/FileLogTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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');