Skip to content

Commit 4ebbe3d

Browse files
Jontsafabpot
authored andcommitted
[Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter
1 parent 44dd80f commit 4ebbe3d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Symfony/Component/Lock/Store/StoreFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public static function createStore($connection)
6666
case 'semaphore' === $connection:
6767
return new SemaphoreStore();
6868

69-
case 0 === strpos($connection, 'redis://'):
70-
case 0 === strpos($connection, 'rediss://'):
71-
case 0 === strpos($connection, 'memcached://'):
69+
case 0 === strpos($connection, 'redis:'):
70+
case 0 === strpos($connection, 'rediss:'):
71+
case 0 === strpos($connection, 'memcached:'):
7272
if (!class_exists(AbstractAdapter::class)) {
7373
throw new InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require symfony/cache".', $connection));
7474
}
75-
$storeClass = 0 === strpos($connection, 'memcached://') ? MemcachedStore::class : RedisStore::class;
75+
$storeClass = 0 === strpos($connection, 'memcached:') ? MemcachedStore::class : RedisStore::class;
7676
$connection = AbstractAdapter::createConnection($connection, ['lazy' => true]);
7777

7878
return new $storeClass($connection);

src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ public function validConnections()
5858
}
5959
if (class_exists(\Memcached::class) && class_exists(AbstractAdapter::class)) {
6060
yield ['memcached://server.com', MemcachedStore::class];
61+
yield ['memcached:?host[localhost]&host[localhost:12345]', MemcachedStore::class];
6162
}
62-
if (class_exists(\Redis::class) && class_exists(AbstractAdapter::class)) {
63+
if ((class_exists(\Redis::class) || class_exists(\Predis\Client::class)) && class_exists(AbstractAdapter::class)) {
6364
yield ['redis://localhost', RedisStore::class];
6465
yield ['redis://localhost?lazy=1', RedisStore::class];
6566
yield ['redis://localhost?redis_cluster=1', RedisStore::class];
6667
yield ['redis://localhost?redis_cluster=1&lazy=1', RedisStore::class];
68+
yield ['redis:?host[localhost]&host[localhost:6379]&redis_cluster=1', RedisStore::class];
6769
}
6870
if (class_exists(\PDO::class)) {
6971
yield ['sqlite:/tmp/sqlite.db', PdoStore::class];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy