diff --git a/examples/src/CustomVariableProvider.php b/examples/src/CustomVariableProvider.php index 2bf6c9a1f..9f4291b6f 100644 --- a/examples/src/CustomVariableProvider.php +++ b/examples/src/CustomVariableProvider.php @@ -37,7 +37,7 @@ class CustomVariableProvider extends StandardVariableProvider implements Variabl public function getByPath($path) { if ($path === 'random') { - return 'random' . sha1(rand(0, 999999999)); + return 'random' . hash('xxh3', (string)rand(0, 999999999)); } if ($path === 'incrementer') { return ++$this->incrementer; diff --git a/src/Core/Compiler/TemplateCompiler.php b/src/Core/Compiler/TemplateCompiler.php index 3cee3659d..f3a95ac5e 100644 --- a/src/Core/Compiler/TemplateCompiler.php +++ b/src/Core/Compiler/TemplateCompiler.php @@ -234,11 +234,7 @@ protected function generateCodeForLayoutName($storedLayoutNameArgument): string return 'return (string)\'' . $storedLayoutNameArgument . '\''; } - /** - * @param ParsingState $parsingState - * @return string - */ - protected function generateSectionCodeFromParsingState(ParsingState $parsingState) + protected function generateSectionCodeFromParsingState(ParsingState $parsingState): string { $generatedRenderFunctions = ''; if ($parsingState->getVariableContainer()->exists('1457379500_sections')) { @@ -249,7 +245,7 @@ protected function generateSectionCodeFromParsingState(ParsingState $parsingStat // @todo: Verify this is *always* an instance of RootNode // and call $node->convert($this) directly. $this->convertSubNodes($sectionRootNode->getChildNodes()), - 'section_' . sha1($sectionName), + 'section_' . hash('xxh3', $sectionName), 'section ' . $sectionName, ); } diff --git a/src/View/AbstractTemplateView.php b/src/View/AbstractTemplateView.php index 82f812b7c..8d0248904 100644 --- a/src/View/AbstractTemplateView.php +++ b/src/View/AbstractTemplateView.php @@ -244,7 +244,7 @@ public function renderSection($sectionName, array $variables = [], $ignoreUnknow } if ($parsedTemplate->isCompiled()) { - $methodNameOfSection = 'section_' . sha1($sectionName); + $methodNameOfSection = 'section_' . hash('xxh3', (string)$sectionName); if (!method_exists($parsedTemplate, $methodNameOfSection)) { if ($ignoreUnknown) { return ''; diff --git a/src/View/TemplatePaths.php b/src/View/TemplatePaths.php index ead6ee67b..56b9cf533 100644 --- a/src/View/TemplatePaths.php +++ b/src/View/TemplatePaths.php @@ -556,7 +556,7 @@ public function getLayoutSource($layoutName = 'Default') public function getTemplateIdentifier($controller = 'Default', $action = 'Default') { if ($this->templateSource !== null) { - return 'source_' . sha1($this->templateSource) . '_' . $controller . '_' . $action . '_' . $this->getFormat(); + return 'source_' . hash('xxh3', (string)$this->templateSource) . '_' . $controller . '_' . $action . '_' . $this->getFormat(); } $templatePathAndFilename = $this->resolveTemplateFileForControllerAndActionAndFormat($controller, $action); $prefix = ltrim($controller . '_action_' . $action, '_'); @@ -610,7 +610,7 @@ public function getTemplateSource($controller = 'Default', $action = 'Default') /** * Returns a unique identifier for the given file in the format - * ____ + * ____ * The SH1 hash is a checksum that is based on the file path and last modification date * * @param string|null $pathAndFilename @@ -621,7 +621,7 @@ protected function createIdentifierForFile($pathAndFilename, $prefix) { $pathAndFilename = (string)$pathAndFilename; $templateModifiedTimestamp = $pathAndFilename !== 'php://stdin' && file_exists($pathAndFilename) ? filemtime($pathAndFilename) : 0; - return sprintf('%s_%s', $prefix, sha1($pathAndFilename . '|' . $templateModifiedTimestamp)); + return sprintf('%s_%s', $prefix, hash('xxh3', $pathAndFilename . '|' . $templateModifiedTimestamp)); } /** diff --git a/tests/Functional/AbstractFunctionalTestCase.php b/tests/Functional/AbstractFunctionalTestCase.php index 8d5d7475f..4e562c211 100644 --- a/tests/Functional/AbstractFunctionalTestCase.php +++ b/tests/Functional/AbstractFunctionalTestCase.php @@ -41,7 +41,7 @@ abstract class AbstractFunctionalTestCase extends BaseTestCase public static function setUpBeforeClass(): void { - self::$cachePath = sys_get_temp_dir() . '/' . 'fluid-functional-tests-' . sha1(__CLASS__); + self::$cachePath = sys_get_temp_dir() . '/' . 'fluid-functional-tests-' . hash('xxh3', __CLASS__); mkdir(self::$cachePath); self::$cache = (new SimpleFileCache(self::$cachePath)); } diff --git a/tests/Unit/View/TemplatePathsTest.php b/tests/Unit/View/TemplatePathsTest.php index 04222325f..93233e026 100644 --- a/tests/Unit/View/TemplatePathsTest.php +++ b/tests/Unit/View/TemplatePathsTest.php @@ -223,7 +223,7 @@ public function testGetTemplateIdentifierReturnsSourceChecksumWithControllerAndA { $instance = new TemplatePaths(); $instance->setTemplateSource('foobar'); - self::assertSame('source_8843d7f92416211de9ebb963ff4ce28125932878_DummyController_dummyAction_html', $instance->getTemplateIdentifier('DummyController', 'dummyAction')); + self::assertSame('source_d78fda63144c5c84_DummyController_dummyAction_html', $instance->getTemplateIdentifier('DummyController', 'dummyAction')); } /**