Issue #4719 - (Redis and Memcached fixes and test)
This commit is contained in:
parent
5def75101e
commit
d1a142ebe8
@ -153,20 +153,27 @@ 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)) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
$indexRow = implode("\t", array(
|
||||
$profile->getToken(),
|
||||
$profile->getIp(),
|
||||
$profile->getMethod(),
|
||||
$profile->getUrl(),
|
||||
$profile->getTime(),
|
||||
$profile->getParentToken(),
|
||||
))."\n";
|
||||
if (!$profileIndexed) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
return $this->appendValue($indexName, $indexRow, $this->lifetime);
|
||||
$indexRow = implode("\t", array(
|
||||
$profile->getToken(),
|
||||
$profile->getIp(),
|
||||
$profile->getMethod(),
|
||||
$profile->getUrl(),
|
||||
$profile->getTime(),
|
||||
$profile->getParentToken(),
|
||||
))."\n";
|
||||
|
||||
return $this->appendValue($indexName, $indexRow, $this->lifetime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -167,20 +167,27 @@ 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)) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
$indexRow = implode("\t", array(
|
||||
$profile->getToken(),
|
||||
$profile->getIp(),
|
||||
$profile->getMethod(),
|
||||
$profile->getUrl(),
|
||||
$profile->getTime(),
|
||||
$profile->getParentToken(),
|
||||
))."\n";
|
||||
if (!$profileIndexed) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
return $this->appendValue($indexName, $indexRow, $this->lifetime);
|
||||
$indexRow = implode("\t", array(
|
||||
$profile->getToken(),
|
||||
$profile->getIp(),
|
||||
$profile->getMethod(),
|
||||
$profile->getUrl(),
|
||||
$profile->getTime(),
|
||||
$profile->getParentToken(),
|
||||
))."\n";
|
||||
|
||||
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