Skip to content

Commit

Permalink
bug #36121 [VarDumper] fix side-effect by not using mt_rand() (nicola…
Browse files Browse the repository at this point in the history
…s-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[VarDumper] fix side-effect by not using mt_rand()

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Reported by @bobthecow on Twitter: using `mt_rand()` breaks inspecting seeded calls to `mt_rand()`.

Should be replaced by a call to `md5(random_bytes(6))` on 4.4.

Commits
-------

8c85f91 [VarDumper] fix side-effect by not using mt_rand()
  • Loading branch information
fabpot committed Mar 18, 2020
2 parents 2baa812 + 8c85f91 commit 5f364af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Cloner/VarCloner.php
Expand Up @@ -48,8 +48,8 @@ protected function doClone($var)
// or null if the original value is used directly

if (!self::$hashMask) {
self::$gid = uniqid(mt_rand(), true); // Unique string used to detect the special $GLOBALS variable
self::initHashMask();
self::$gid = md5(dechex(self::$hashMask)); // Unique string used to detect the special $GLOBALS variable
}
$gid = self::$gid;
$hashMask = self::$hashMask;
Expand Down

0 comments on commit 5f364af

Please sign in to comment.