Description
Symfony version(s) affected: 4.4-dev
Blocks #41552
Description
ContainerBuilder
comes with a handy hash()
function that is used to produce file names of dumped containers or unique service IDs.
symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
Lines 1571 to 1576 in a1f376b
Because of a failing test (PhpDumperTest::testServiceSubscriber
) I noticed that the produced hash on PHP 8.1 differs from the one we've created on PHP 8.0. The test compares the result of dumping a container against a fixture. That fixture contains such a hash and is currently used in unit tests with PHP versions 7.1 through 8.0.
I've dumped the result of serialize()
on PHP 8.0 and 8.1 and got different results. At first glace, it appears that the properties of the serialized objects appear in a different order on PHP 8.0 and below than on 8.1. For the sole purpose of serializing and unserializing objects, this probably does not matter, but if the serialized string is used as input for a hash function, this becomes a problem.
Question is: Is that hash meant to remain stable across PHP versions?
- If the answer is no, we could either produce a second version of that fixture or find a way to make the test more resilient against hash changes. I don't know yet, if there are more test failures related to that issue, though.
- If the answer is yes: Can we find a more stable way to calculate those hashes? Or is this something we should report to the PHP team?