10000 [Debug] Remove GLOBALS from exception context to avoid endless recursion · symfony/symfony@a325f1f · GitHub
[go: up one dir, main page]

Skip to content

Commit a325f1f

Browse files
committed
[Debug] Remove GLOBALS from exception context to avoid endless recursion
1 parent 2cf474e commit a325f1f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ public function handleError($type, $message, $file, $line, array $context, array
420420
self::$toStringException = null;
421421
} elseif (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
422422
// Checking for class existence is a work around for https://bugs.php.net/42098
423+
424+
// if GLOBALS is included because an error occured in global scope, and it
425+
// contains a reference to itself, we unset it to avoid endless recursion
426+
// later on when the context is normalized and iterated over by Monolog
427+
if (isset($context['GLOBALS']['GLOBALS']['GLOBALS'])) {
428+
unset($context['GLOBALS']);
429+
}
430+
423431
$throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
424432
} else {
425433
$throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);

0 commit comments

Comments
 (0)
0