Skip to content

Commit b0c2ee3

Browse files
committed
Use DSN for lock configuration too
1 parent 6c4d771 commit b0c2ee3

22 files changed

+53
-353
lines changed

UPGRADE-4.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
UPGRADE FROM 3.x to 4.0
22
=======================
33

4+
Cache
5+
-----
6+
7+
* The `AbstractAdapter::createConnection()`, `RedisTrait::createConnection()`
8+
and `MemcachedTrait::createConnection()` methods have been removed. Use the
9+
Dsn component instead.
10+
411
ClassLoader
512
-----------
613

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
1919
use Symfony\Component\DependencyInjection\Definition;
20+
use Symfony\Component\DependencyInjection\Exception\LogicException;
2021
use Symfony\Component\DependencyInjection\Reference;
2122
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2223
use Symfony\Component\Dsn\ConnectionFactory;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
4444
use Symfony\Component\DependencyInjection\Reference;
4545
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
46+
use Symfony\Component\Dsn\ConnectionFactory;
4647
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
4748
use Symfony\Component\EventDispatcher\EventDispatcher;
4849
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -1706,7 +1707,7 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
17061707
if (!$container->hasDefinition($connectionDefinitionId = $container->hash($storeDsn))) {
17071708
$connectionDefinition = new Definition(\stdClass::class);
17081709
$connectionDefinition->setPublic(false);
1709-
$connectionDefinition->setFactory(array(StoreFactory::class, 'createConnection'));
1710+
$connectionDefinition->setFactory(array(ConnectionFactory::class, 'createConnection'));
17101711
$connectionDefinition->setArguments(array($storeDsn));
17111712
$container->setDefinition($connectionDefinitionId, $connectionDefinition);
17121713
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"symfony/browser-kit": "~2.8|~3.0|~4.0",
3838
"symfony/console": "~3.4|~4.0",
3939
"symfony/css-selector": "~2.8|~3.0|~4.0",
40+
"symfony/dsn": "~3.4",
4041
"symfony/dom-crawler": "~2.8|~3.0|~4.0",
4142
"symfony/polyfill-intl-icu": "~1.0",
4243
"symfony/security": "~2.8|~3.0|~4.0",

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
use Symfony\Component\Cache\Traits\AbstractTrait;
2222
use Symfony\Component\Dsn\ConnectionFactory;
2323
use Symfony\Component\Dsn\Exception\InvalidArgumentException as DsnInvalidArgumentException;
24-
use Symfony\Component\Dsn\Factory\MemcachedConnectionFactory;
25-
use Symfony\Component\Dsn\Factory\RedisConnectionFactory;
24+
use Symfony\Component\Dsn\Factory\MemcachedFactory;
25+
use Symfony\Component\Dsn\Factory\RedisFactory;
2626

2727
/**
2828
* @author Nicolas Grekas <p@tchwork.com>
@@ -132,7 +132,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
132132

133133
public static function createConnection($dsn, array $options = array())
134134
{
135-
@trigger_error(sprintf('The %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the DsnFactory::createConnection() method from Dsn component instead.', __METHOD__), E_USER_DEPRECATED);
135+
@trigger_error(sprintf('The %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the ConnectionFactory::create() method from Dsn component instead.', __METHOD__), E_USER_DEPRECATED);
136136

137137
try {
138138
$type = ConnectionFactory::getType($dsn);
@@ -142,9 +142,9 @@ public static function createConnection($dsn, array $options = array())
142142

143143
switch ($type) {
144144
case ConnectionFactory::TYPE_MEMCACHED:
145-
return MemcachedConnectionFactory::createConnection($dsn, $options);
145+
return MemcachedFactory::create($dsn, $options);
146146
case ConnectionFactory::TYPE_REDIS:
147-
return RedisConnectionFactory::createConnection($dsn, $options);
147+
return RedisFactory::create($dsn, $options);
148148
}
149149

150150
throw new InvalidArgumentException(sprintf('Unsupported DSN: %s.', $dsn));

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MemcachedAdapter extends AbstractAdapter
2525
* Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged.
2626
* Using a RedisAdapter is recommended instead. If you cannot do otherwise, be aware that:
2727
* - the Memcached::OPT_BINARY_PROTOCOL must be enabled
28-
* (that's the default when using MemcachedAdapter::createConnection());
28+
* (that's the default when using MemcachedFactory::create());
2929
* - tags eviction by Memcached's LRU algorithm will break by-tags invalidation;
3030
* your Memcached memory should be large enough to never trigger LRU.
3131
*

src/Symfony/Component/Cache/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ CHANGELOG
99
* added prune logic to FilesystemTrait, PhpFilesTrait, PdoTrait, TagAwareAdapter and ChainTrait
1010
* now FilesystemAdapter, PhpFilesAdapter, FilesystemCache, PhpFilesCache, PdoAdapter, PdoCache, ChainAdapter, and
1111
ChainCache implement PruneableInterface and support manual stale cache pruning
12+
* deprecated `AbstractAdapter::createConnection()`, `RedisTrait::createConnection()` and
13+
`MemcachedTrait::createConnection()`
1214

1315
3.3.0
1416
-----

src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

1414
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
15+
use Symfony\Component\Dsn\Factory\MemcachedFactory;
1516

1617
class MemcachedAdapterTest extends AdapterTestCase
1718
{
@@ -27,7 +28,7 @@ public static function setupBeforeClass()
2728
if (!MemcachedAdapter::isSupported()) {
2829
self::markTestSkipped('Extension memcached >=2.2.0 required.');
2930
}
30-
self::$client = MemcachedConnectionFactory::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false));
31+
self::$client = MemcachedFactory::create('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false));
3132
self::$client->get('foo');
3233
$code = self::$client->getResultCode();
3334

@@ -38,14 +39,14 @@ public static function setupBeforeClass()
3839

3940
public function createCachePool($defaultLifetime = 0)
4041
{
41-
$client = $defaultLifetime ? MemcachedConnectionFactory::createConnection('memcached://'.getenv('MEMCACHED_HOST')) : self::$client;
42+
$client = $defaultLifetime ? MemcachedFactory::create('memcached://'.getenv('MEMCACHED_HOST')) : self::$client;
4243

4344
return new MemcachedAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
4445
}
4546

4647
/**
4748
* @group legacy
48-
* @expectedDeprecation This "%s" method is deprecated.
49+
* @expectedDeprecation The %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the MemcachedFactory::create() method from Dsn component instead.
4950
*/
5051
public function testCreateConnectionDeprecated()
5152
{

src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ public static function setupBeforeClass()
2424

2525
/**
2626
* @group legacy
27-
* @expectedDeprecation This "%s" method is deprecated.
27+
* @expectedDeprecation The %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the RedisFactory::create() method from Dsn component instead.
2828
*/
2929
public function testCreateConnectionDeprecated()
3030
{
31-
$client = RedisAdapter::createConnection('redis://'.getenv('REDIS_HOST'));
32-
33-
$this->assertInstanceOf(\Predis\Client, $client);
31+
RedisAdapter::createConnection('redis://'.getenv('REDIS_HOST'));
3432
}
3533

3634
/**

src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313

1414
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1515
use Symfony\Component\Cache\Adapter\RedisAdapter;
16+
use Symfony\Component\Dsn\Factory\RedisFactory;
1617

1718
class RedisAdapterTest extends AbstractRedisAdapterTest
1819
{
1920
public static function setupBeforeClass()
2021
{
2122
parent::setupBeforeClass();
22-
self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'));
23+
self::$redis = RedisFactory::create('redis://'.getenv('REDIS_HOST'));
2324
}
2425

2526
/**
2627
* @group legacy
27-
* @expectedDeprecation This "%s" method is deprecated.
28+
* @expectedDeprecation The %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the RedisFactory::create() method from Dsn component instead.
2829
*/
2930
public function testCreateConnectionDeprecated()
3031
{

0 commit comments

Comments
 (0)