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 b0c2ee3

Browse filesBrowse files
committed
Use DSN for lock configuration too
1 parent 6c4d771 commit b0c2ee3
Copy full SHA for b0c2ee3

22 files changed

+53
-353
lines changed

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+7Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php
+1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+2-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
+5-5Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/CHANGELOG.md
+2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php
+4-3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php
+2-4Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php
+3-2Lines 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
{

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Cache\Tests\Simple;
1313

1414
use Symfony\Component\Cache\Simple\MemcachedCache;
15-
use Symfony\Component\Dsn\Factory\MemcachedConnectionFactory;
15+
use Symfony\Component\Dsn\Factory\MemcachedFactory;
1616

1717
class MemcachedCacheTest extends CacheTestCase
1818
{
@@ -29,7 +29,7 @@ public static function setupBeforeClass()
2929
if (!MemcachedCache::isSupported()) {
3030
self::markTestSkipped('Extension memcached >=2.2.0 required.');
3131
}
32-
self::$client = MemcachedConnectionFactory::createConnection('memcached://'.getenv('MEMCACHED_HOST'));
32+
self::$client = MemcachedFactory::create('memcached://'.getenv('MEMCACHED_HOST'));
3333
self::$client->get('foo');
3434
$code = self::$client->getResultCode();
3535

@@ -40,7 +40,7 @@ public static function setupBeforeClass()
4040

4141
public function createSimpleCache($defaultLifetime = 0)
4242
{
43-
$client = $defaultLifetime ? MemcachedConnectionFactory::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false)) : self::$client;
43+
$client = $defaultLifetime ? MemcachedFactory::create('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false)) : self::$client;
4444

4545
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
4646
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,23 @@
1212
namespace Symfony\Component\Cache\Tests\Simple;
1313

1414
use Symfony\Component\Cache\Simple\RedisCache;
15+
use Symfony\Component\Dsn\Factory\RedisFactory;
1516

1617
class RedisCacheTest extends AbstractRedisCacheTest
1718
{
1819
public static function setupBeforeClass()
1920
{
2021
parent::setupBeforeClass();
21-
self::$redis = RedisCache::createConnection('redis://'.getenv('REDIS_HOST'));
22+
self::$redis = RedisFactory::create('redis://'.getenv('REDIS_HOST'));
2223
}
2324

2425
/**
2526
* @group legacy
26-
* @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.
2728
*/
2829
public function testCreateConnectionDeprecated()
2930
{
30-
$client = RedisCache::createConnection('redis://'.getenv('REDIS_HOST'));
31-
32-
$this->assertInstanceOf(\Predis\Client, $client);
31+
RedisCache::createConnection('redis://'.getenv('REDIS_HOST'));
3332
}
3433

3534
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/MemcachedTrait.php
+5-9Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Cache\Exception\CacheException;
1515
use Symfony\Component\Cache\Exception\InvalidArgumentException;
16-
use Symfony\Component\Dsn\Factory\MemcachedConnectionFactory;
16+
use Symfony\Component\Dsn\Factory\MemcachedFactory;
1717

1818
/**
1919
* @author Rob Frawley 2nd <rmf@src.run>
@@ -52,15 +52,15 @@ private function init(\Memcached $client, $namespace, $defaultLifetime)
5252
}
5353

5454
/**
55-
* @see MemcachedConnectionFactory::createConnection()
55+
* @see MemcachedFactory::create()
5656
*/
5757
public static function createConnection($servers, array $options = array())
5858
{
59-
@trigger_error(sprintf('The %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the MemcachedDsnFactory::createConnection() method from Dsn component instead.', __METHOD__), E_USER_DEPRECATED);
59+
@trigger_error(sprintf('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.', __METHOD__), E_USER_DEPRECATED);
6060

6161
foreach ((array) $servers as $i => $dsn) {
6262
if (is_array($dsn)) {
63-
@trigger_error(sprintf('Passing an array of array to the %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the MemcachedDsnFactory::createConnection() method from Dsn component instead with an array of Dsn instead.', __METHOD__), E_USER_DEPRECATED);
63+
@trigger_error(sprintf('Passing an array of array to 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 with an array of Dsn instead.', __METHOD__), E_USER_DEPRECATED);
6464

6565
$scheme = 'memcached://';
6666
$host = isset($dsn['host']) ? $dsn['host'] : '';
@@ -81,16 +81,12 @@ public static function createConnection($servers, array $options = array())
8181
}
8282

8383
try {
84-
return MemcachedConnectionFactory::createConnection($servers, $options);
84+
return MemcachedFactory::create($servers, $options);
8585
} catch (\Symfony\Component\Dsn\Exception\InvalidArgumentException $e) {
8686
throw new InvalidArgumentException($e->getMessage(), 0, $e);
8787
}
8888
}
8989

90-
private static function buildDsn($parsedDsn)
91-
{
92-
}
93-
9490
/**
9591
* {@inheritdoc}
9692
*/

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/RedisTrait.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Predis\Connection\Aggregate\RedisCluster;
1717
use Predis\Response\Status;
1818
use Symfony\Component\Cache\Exception\InvalidArgumentException;
19-
use Symfony\Component\Dsn\Factory\RedisConnectionFactory;
19+
use Symfony\Component\Dsn\Factory\RedisFactory;
2020

2121
/**
2222
* @author Aurimas Niekis <aurimas@niekis.lt>
@@ -47,14 +47,14 @@ public function init($redisClient, $namespace = '', $defaultLifetime = 0)
4747
}
4848

4949
/**
50-
* @see RedisConnectionFactory::createConnection()
50+
* @see RedisFactory::create()
5151
*/
5252
public static function createConnection($dsn, array $options = array())
5353
{
54-
@trigger_error(sprintf('The %s() method is deprecated since version 3.4 and will be removed in 4.0. Use the RedisDsnFactory::createConnection() method from Dsn component instead.', __METHOD__), E_USER_DEPRECATED);
54+
@trigger_error(sprintf('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.', __METHOD__), E_USER_DEPRECATED);
5555

5656
try {
57-
return RedisConnectionFactory::createConnection($dsn, $options);
57+
return RedisFactory::create($dsn, $options);
5858
} catch (\Symfony\Component\Dsn\Exception\InvalidArgumentException $e) {
5959
throw new InvalidArgumentException($e->getMessage(), 0, $e);
6060
}

‎src/Symfony/Component/Cache/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/composer.json
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
"predis/predis": "~1.0",
3434
"symfony/dsn": "3.4"
3535
},
36+
"suggest": {
37+
"symfony/dsn": "For configuring redis and memcached adapters with Dsn"
38+
},
3639
"conflict": {
3740
"symfony/var-dumper": "<3.3"
3841
},

‎src/Symfony/Component/Dsn/Factory/RedisFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/Factory/RedisFactory.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Dsn\Factory;
1313

14+
use Predis\Connection\Factory;
1415
use Symfony\Component\Dsn\Exception\InvalidArgumentException;
1516

1617
/**

‎src/Symfony/Component/Dsn/README.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/README.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Dsn Component
22
=============
33

4-
Provides utilities for handle Data Source Names.
4+
Provides utilities for creating connections using DSN (Data Source Names)
5+
strings.
56

67
Resources
78
---------

0 commit comments

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