Skip to content

Commit 787d364

Browse files
committed
update xxh128 hash instead of md5
1 parent 2798f03 commit 787d364

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/Symfony/Component/SerDes/Instantiator/LazyInstantiator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __invoke(\ReflectionClass $class, array $propertiesValues, array
4646
}
4747

4848
if (!isset(self::$lazyClassesLoaded[$className]) && !class_exists(self::$cache['lazy_class_name'][$className])) {
49-
if (!file_exists($path = sprintf('%s%s%s.php', $this->cacheDir, \DIRECTORY_SEPARATOR, md5($className)))) {
49+
if (!file_exists($path = sprintf('%s%s%s.php', $this->cacheDir, \DIRECTORY_SEPARATOR, hash('xxh128', $className)))) {
5050
if (!file_exists($this->cacheDir)) {
5151
mkdir($this->cacheDir, recursive: true);
5252
}
@@ -55,7 +55,7 @@ public function __invoke(\ReflectionClass $class, array $propertiesValues, array
5555
file_put_contents($path, sprintf('class %s%s', $lazyClassName, ProxyHelper::generateLazyGhost($class)));
5656
}
5757

58-
eval(file_get_contents(sprintf('%s%s%s.php', $this->cacheDir, \DIRECTORY_SEPARATOR, md5($className))));
58+
eval(file_get_contents(sprintf('%s%s%s.php', $this->cacheDir, \DIRECTORY_SEPARATOR, hash('xxh128', $className))));
5959

6060
self::$lazyClassesLoaded[$className] = true;
6161
}

src/Symfony/Component/SerDes/Resources/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function serialize(mixed $data, $resource, string $format, array $context = []):
3737
$type = $context['type'] ?? get_debug_type($data);
3838

3939
$cacheDir = $context['cache_dir'] ?? sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfony_ser_des';
40-
$cacheFilename = sprintf('%s%s%s.%s.php', $cacheDir, \DIRECTORY_SEPARATOR, md5($type), $format);
40+
$cacheFilename = sprintf('%s%s%s.%s.php', $cacheDir, \DIRECTORY_SEPARATOR, hash('xxh128', $type), $format);
4141

4242
if (!file_exists($cacheFilename)) {
4343
if (!file_exists($cacheDir)) {

src/Symfony/Component/SerDes/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function serialize(mixed $data, string $format, mixed $output, ContextInt
4646

4747
$context['type'] = $context['type'] ?? get_debug_type($data);
4848
$context['cache_dir'] = $context['cache_dir'] ?? $this->templateCacheDir;
49-
$context['template_exists'] = file_exists(sprintf('%s%s%s.%s.php', $context['cache_dir'], \DIRECTORY_SEPARATOR, md5($context['type']), $format));
49+
$context['template_exists'] = file_exists(sprintf('%s%s%s.%s.php', $context['cache_dir'], \DIRECTORY_SEPARATOR, hash('xxh128', $context['type']), $format));
5050

5151
foreach ($this->serializeContextBuilders as $contextBuilder) {
5252
$context = $contextBuilder->build($context);

src/Symfony/Component/SerDes/Tests/Internal/Serialize/SerializeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testCreateCacheFileInCustomDirectory()
5959

6060
public function testCreateCacheFileOnlyIfNotExists()
6161
{
62-
$cacheFilename = sprintf('%s/%s.json.php', $this->cacheDir, md5('int'));
62+
$cacheFilename = sprintf('%s/%s.json.php', $this->cacheDir, hash('xxh128', 'int'));
6363
if (!file_exists($this->cacheDir)) {
6464
mkdir($this->cacheDir, recursive: true);
6565
}

0 commit comments

Comments
 (0)