bug #36993 [ErrorHandler] fix setting $trace to null in FatalError (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] fix setting $trace to null in FatalError

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

Spotted by @nikic in https://github.com/php/php-src/pull/5620#issuecomment-635258024

Commits
-------

aa50c9287c [ErrorHandler] fix setting $trace to null in FatalError
This commit is contained in:
Nicolas Grekas 2020-05-28 14:15:08 +02:00
commit 0d2bc7bd6a
1 changed files with 5 additions and 3 deletions

View File

@ -72,9 +72,11 @@ class FatalError extends \Error
'line' => $error['line'],
'trace' => $trace,
] as $property => $value) {
$refl = new \ReflectionProperty(\Error::class, $property);
$refl->setAccessible(true);
$refl->setValue($this, $value);
if (null !== $value) {
$refl = new \ReflectionProperty(\Error::class, $property);
$refl->setAccessible(true);
$refl->setValue($this, $value);
}
}
}