bug #36121 [VarDumper] fix side-effect by not using mt_rand() (nicolas-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
-------

8c85f91b9c [VarDumper] fix side-effect by not using mt_rand()
This commit is contained in:
Fabien Potencier 2020-03-18 08:13:59 +01:00
commit 5f364af6a0

View File

@ -48,8 +48,8 @@ class VarCloner extends AbstractCloner
// 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;