Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit af06990

Browse filesBrowse files
Aleksey Prilipkonicolas-grekas
Aleksey Prilipko
authored andcommitted
bug #27299 [Cache] memcache connect should not add duplicate entries on sequential calls
1 parent 13be093 commit af06990
Copy full SHA for af06990

File tree

2 files changed

+12
-3
lines changed
Filter options

2 files changed

+12
-3
lines changed

‎src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ public function createSimpleCache($defaultLifetime = 0)
4545
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
4646
}
4747

48+
public function testCreatePersistentConnectionShouldNotDupServerList()
49+
{
50+
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent'));
51+
$this->assertCount(1, $instance->getServerList());
52+
53+
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent'));
54+
$this->assertCount(1, $instance->getServerList());
55+
}
56+
4857
public function testOptions()
4958
{
5059
$client = MemcachedCache::createConnection(array(), array(

‎src/Symfony/Component/Cache/Traits/MemcachedTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/MemcachedTrait.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ public static function createConnection($servers, array $options = array())
169169
}
170170

171171
if ($oldServers !== $newServers) {
172-
// before resetting, ensure $servers is valid
173-
$client->addServers($servers);
174172
$client->resetServerList();
173+
$client->addServers($servers);
175174
}
175+
} else {
176+
$client->addServers($servers);
176177
}
177-
$client->addServers($servers);
178178

179179
if (null !== $username || null !== $password) {
180180
if (!method_exists($client, 'setSaslAuthData')) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.