diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index e2e259194d..7adde3f3c3 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -58,10 +58,7 @@ class FileProfilerStorage implements ProfilerStorageInterface fseek($file, 0, SEEK_END); $result = array(); - - while ($limit > 0) { - $line = $this->readLineFromFile($file); - + while (count($result) < $limit && $line = $this->readLineFromFile($file)) { if (false === $line) { break; } @@ -84,7 +81,6 @@ class FileProfilerStorage implements ProfilerStorageInterface 'time' => $csvTime, 'parent' => $csvParent, ); - --$limit; } fclose($file); diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php index 62f24ce87a..e3f024eef3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php @@ -183,6 +183,21 @@ abstract class AbstractProfilerStorageTest extends \PHPUnit_Framework_TestCase $this->getStorage()->purge(); } + public function testRetrieveByMethodAndLimit() + { + foreach (array('POST', 'GET') as $method) { + for ($i = 0; $i < 5; $i++) { + $profile = new Profile('token_'.$i.$method); + $profile->setMethod($method); + $this->getStorage()->write($profile); + } + } + + $this->assertCount(5, $this->getStorage()->find('', '', 5, 'POST')); + + $this->getStorage()->purge(); + } + public function testPurge() { $profile = new Profile('token1');