Skip to content

Commit cf88977

Browse files
committed
minor #23766 Consistently use 7 chars of sha256 for hash-based id generation (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- Consistently use 7 chars of sha256 for hash-based id generation | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This prevents generating over long service ids, and for filesystem-related changes, makes the Windows 258 chars limit farther. Commits ------- bc22cdd034 Consistently use 7 chars of sha256 for hash-based id generation
2 parents 287dba9 + dd98d4b commit cf88977

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

DependencyInjection/Compiler/CachePoolPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static function getServiceProvider(ContainerBuilder $container, $name)
111111
if ($usedEnvs || preg_match('#^[a-z]++://#', $name)) {
112112
$dsn = $name;
113113

114-
if (!$container->hasDefinition($name = md5($dsn))) {
114+
if (!$container->hasDefinition($name = 'cache_connection.'.ContainerBuilder::hash($dsn))) {
115115
$definition = new Definition(AbstractAdapter::class);
116116
$definition->setPublic(false);
117117
$definition->setFactory(array(AbstractAdapter::class, 'createConnection'));

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ public function testCacheDefaultRedisProvider()
937937
$container = $this->createContainerFromFile('cache');
938938

939939
$redisUrl = 'redis://localhost';
940-
$providerId = md5($redisUrl);
940+
$providerId = 'cache_connection.'.ContainerBuilder::hash($redisUrl);
941941

942942
$this->assertTrue($container->hasDefinition($providerId));
943943

@@ -951,7 +951,7 @@ public function testCacheDefaultRedisProviderWithEnvVar()
951951
$container = $this->createContainerFromFile('cache_env_var');
952952

953953
$redisUrl = 'redis://paas.com';
954-
$providerId = md5($redisUrl);
954+
$providerId = 'cache_connection.'.ContainerBuilder::hash($redisUrl);
955955

956956
$this->assertTrue($container->hasDefinition($providerId));
957957

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ext-xml": "*",
2121
"symfony/cache": "~3.4|~4.0",
2222
"symfony/class-loader": "~3.2",
23-
"symfony/dependency-injection": "~3.3|~4.0",
23+
"symfony/dependency-injection": "~3.4|~4.0",
2424
"symfony/config": "~3.3|~4.0",
2525
"symfony/event-dispatcher": "^3.3.1|~4.0",
2626
"symfony/http-foundation": "~3.3|~4.0",

0 commit comments

Comments
 (0)