Issue #4719 - (Redis and Memcached fixes and test)
This commit is contained in:
parent
5def75101e
commit
d1a142ebe8
@ -153,7 +153,11 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface
|
||||
'time' => $profile->getTime(),
|
||||
);
|
||||
|
||||
$profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken()));
|
||||
|
||||
if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) {
|
||||
|
||||
if (!$profileIndexed) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
@ -169,6 +173,9 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface
|
||||
return $this->appendValue($indexName, $indexRow, $this->lifetime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,11 @@ class RedisProfilerStorage implements ProfilerStorageInterface
|
||||
'time' => $profile->getTime(),
|
||||
);
|
||||
|
||||
$profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken()));
|
||||
|
||||
if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, self::REDIS_SERIALIZER_PHP)) {
|
||||
|
||||
if (!$profileIndexed) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
@ -183,6 +187,9 @@ class RedisProfilerStorage implements ProfilerStorageInterface
|
||||
return $this->appendValue($indexName, $indexRow, $this->lifetime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -209,6 +209,22 @@ abstract class AbstractProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertCount(0, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'), '->purge() removes all items from index');
|
||||
}
|
||||
|
||||
public function testDuplicates()
|
||||
{
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$profile = new Profile('foo' . $i);
|
||||
$profile->setIp('127.0.0.1');
|
||||
$profile->setUrl('http://example.net/');
|
||||
$profile->setMethod('GET');
|
||||
|
||||
///three duplicates
|
||||
$this->getStorage()->write($profile);
|
||||
$this->getStorage()->write($profile);
|
||||
$this->getStorage()->write($profile);
|
||||
}
|
||||
$this->assertCount(3, $this->getStorage()->find('127.0.0.1', 'http://example.net/', 3, 'GET'), '->find() method returns incorrect number of entries');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface
|
||||
*/
|
||||
|
Reference in New Issue
Block a user