bug #30350 [VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Fixes the root issue that led to https://github.com/symfony/symfony/pull/30311#issuecomment-466457434
Commits
-------
29a0683107
[VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning
This commit is contained in:
commit
83fec23d61
@ -33,6 +33,7 @@ class VarCloner extends AbstractCloner
|
|||||||
$indexedArrays = []; // Map of queue indexes that hold numerically indexed arrays
|
$indexedArrays = []; // Map of queue indexes that hold numerically indexed arrays
|
||||||
$hardRefs = []; // Map of original zval hashes to stub objects
|
$hardRefs = []; // Map of original zval hashes to stub objects
|
||||||
$objRefs = []; // Map of original object handles to their stub object counterpart
|
$objRefs = []; // Map of original object handles to their stub object counterpart
|
||||||
|
$objects = []; // Keep a ref to objects to ensure their handle cannot be reused while cloning
|
||||||
$resRefs = []; // Map of original resource handles to their stub object counterpart
|
$resRefs = []; // Map of original resource handles to their stub object counterpart
|
||||||
$values = []; // Map of stub objects' hashes to original values
|
$values = []; // Map of stub objects' hashes to original values
|
||||||
$maxItems = $this->maxItems;
|
$maxItems = $this->maxItems;
|
||||||
@ -200,6 +201,7 @@ class VarCloner extends AbstractCloner
|
|||||||
}
|
}
|
||||||
if (empty($objRefs[$h])) {
|
if (empty($objRefs[$h])) {
|
||||||
$objRefs[$h] = $stub;
|
$objRefs[$h] = $stub;
|
||||||
|
$objects[] = $v;
|
||||||
} else {
|
} else {
|
||||||
$stub = $objRefs[$h];
|
$stub = $objRefs[$h];
|
||||||
++$stub->refCount;
|
++$stub->refCount;
|
||||||
|
Reference in New Issue
Block a user