use while loop for iterating
The other method limits the number of results without taking the constraints into account. Fixes GH-7883
This commit is contained in:
parent
ca4fb5530e
commit
fbe039bfca
@ -58,10 +58,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
|||||||
fseek($file, 0, SEEK_END);
|
fseek($file, 0, SEEK_END);
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
while (count($result) < $limit && $line = $this->readLineFromFile($file)) {
|
||||||
while ($limit > 0) {
|
|
||||||
$line = $this->readLineFromFile($file);
|
|
||||||
|
|
||||||
if (false === $line) {
|
if (false === $line) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -84,7 +81,6 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
|||||||
'time' => $csvTime,
|
'time' => $csvTime,
|
||||||
'parent' => $csvParent,
|
'parent' => $csvParent,
|
||||||
);
|
);
|
||||||
--$limit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
@ -183,6 +183,21 @@ abstract class AbstractProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->getStorage()->purge();
|
$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()
|
public function testPurge()
|
||||||
{
|
{
|
||||||
$profile = new Profile('token1');
|
$profile = new Profile('token1');
|
||||||
|
Reference in New Issue
Block a user