You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VarCloner::cloneVar fails when cloning $GLOBALS, if $GLOBALS is used in spl_autoload_register callback.
This happens because VarCloner::cloneVar replaces $GLOBALS with an instance of Symfony\Component\VarDumper\Cloner\Stub. $GLOBALS is returned to the original array, once the method execution ends.
Normally, this is not an issue, because third-party code does not execute between this period. But if $GLOBALS is used in an autoload handler, the the handler may be invoked before $GLOBALS can be reset to its original value.
…s-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[VarDumper] fix mutating $GLOBALS while cloning it
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#39679
| License | MIT
| Doc PR | -
Also preparing for https://wiki.php.net/rfc/restrict_globals_usage
Commits
-------
384b0ad [VarDumper] fix mutating $GLOBALS while cloning it
Symfony version(s) affected: 5.1.0
Description
VarCloner::cloneVar
fails when cloning$GLOBALS
, if$GLOBALS
is used inspl_autoload_register
callback.This happens because
VarCloner::cloneVar
replaces$GLOBALS
with an instance ofSymfony\Component\VarDumper\Cloner\Stub
.$GLOBALS
is returned to the original array, once the method execution ends.Normally, this is not an issue, because third-party code does not execute between this period. But if
$GLOBALS
is used in an autoload handler, the the handler may be invoked before$GLOBALS
can be reset to its original value.How to reproduce
Example 1: Minimal Reproducible Example
Example 2
I am getting the error with Whoops error handler, which uses symfony var dumper.
Possible Solution
Additional context
The text was updated successfully, but these errors were encountered: