From 3a319e481a15cff4e3c17ab269295e57d7e827fc Mon Sep 17 00:00:00 2001 From: Ralph Schindler Date: Mon, 12 Apr 2021 11:48:10 -0500 Subject: [PATCH 1/2] Better fix for xdebug >= 3.0 when trying to produce a trace during Fatal Error situations --- src/Symfony/Component/ErrorHandler/Error/FatalError.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/ErrorHandler/Error/FatalError.php b/src/Symfony/Component/ErrorHandler/Error/FatalError.php index 57fc690e26d6c..70e28819fe4be 100644 --- a/src/Symfony/Component/ErrorHandler/Error/FatalError.php +++ b/src/Symfony/Component/ErrorHandler/Error/FatalError.php @@ -33,7 +33,9 @@ public function __construct(string $message, int $code, array $error, int $trace } } } elseif (null !== $traceOffset) { - if (\function_exists('xdebug_get_function_stack') && $trace = @xdebug_get_function_stack()) { + // xdebug >= 3.0 has an ini xdebug.mode (not present in v2) that must be set to 'develop' for xdebug_get_function_stack() + if (\function_exists('xdebug_get_function_stack') && in_array(ini_get('xdebug.mode'), ['develop', false], true)) { + $trace = xdebug_get_function_stack(); if (0 < $traceOffset) { array_splice($trace, -$traceOffset); } From 4c108bd6a66ec44746aac38dfbf2eda0ef878aec Mon Sep 17 00:00:00 2001 From: Ralph Schindler Date: Mon, 12 Apr 2021 12:43:27 -0500 Subject: [PATCH 2/2] CS Fix --- src/Symfony/Component/ErrorHandler/Error/FatalError.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/ErrorHandler/Error/FatalError.php b/src/Symfony/Component/ErrorHandler/Error/FatalError.php index 70e28819fe4be..5a96a94ad1959 100644 --- a/src/Symfony/Component/ErrorHandler/Error/FatalError.php +++ b/src/Symfony/Component/ErrorHandler/Error/FatalError.php @@ -34,7 +34,7 @@ public function __construct(string $message, int $code, array $error, int $trace } } elseif (null !== $traceOffset) { // xdebug >= 3.0 has an ini xdebug.mode (not present in v2) that must be set to 'develop' for xdebug_get_function_stack() - if (\function_exists('xdebug_get_function_stack') && in_array(ini_get('xdebug.mode'), ['develop', false], true)) { + if (\function_exists('xdebug_get_function_stack') && \in_array(ini_get('xdebug.mode'), ['develop', false], true)) { $trace = xdebug_get_function_stack(); if (0 < $traceOffset) { array_splice($trace, -$traceOffset);