Skip to content

Commit 24232e8

Browse files
[Cache] Make directory hashing case insensitive
1 parent 4a8b7cf commit 24232e8

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
@@ -84,7 +84,7 @@ public function process(ContainerBuilder $container)
8484

8585
private function getNamespace($namespaceSuffix, $id)
8686
{
87-
return substr(str_replace('/', '-', base64_encode(md5($id.$namespaceSuffix, true))), 0, 10);
87+
return substr(str_replace('/', '-', base64_encode(hash('sha256', $id.$namespaceSuffix, true))), 0, 10);
8888
}
8989

9090
/**

DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
10371037

10381038
private function registerCacheConfiguration(array $config, ContainerBuilder $container)
10391039
{
1040-
$version = substr(str_replace('/', '-', base64_encode(md5(uniqid(mt_rand(), true), true))), 0, -2);
1040+
$version = substr(str_replace('/', '-', base64_encode(hash('sha256', uniqid(mt_rand(), true), true))), 0, 22);
10411041
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
10421042
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
10431043
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);

Tests/DependencyInjection/Compiler/CachePoolPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testNamespaceArgumentIsReplaced()
4141

4242
$this->cachePoolPass->process($container);
4343

44-
$this->assertSame('VcRIZlUhEv', $cachePool->getArgument(0));
44+
$this->assertSame('kRFqMp5odS', $cachePool->getArgument(0));
4545
}
4646

4747
public function testArgsAreReplaced()
@@ -61,7 +61,7 @@ public function testArgsAreReplaced()
6161

6262
$this->assertInstanceOf(Reference::class, $cachePool->getArgument(0));
6363
$this->assertSame('foobar', (string) $cachePool->getArgument(0));
64-
$this->assertSame('VcRIZlUhEv', $cachePool->getArgument(1));
64+
$this->assertSame('kRFqMp5odS', $cachePool->getArgument(1));
6565
$this->assertSame(3, $cachePool->getArgument(2));
6666
}
6767

0 commit comments

Comments
 (0)