Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fdb117e

Browse filesBrowse files
Merge branch '6.4' into 7.1
* 6.4: Tweak error/exception handler registration
2 parents 8fb59cc + 33050e3 commit fdb117e
Copy full SHA for fdb117e

File tree

Expand file treeCollapse file tree

8 files changed

+52
-23
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+52
-23
lines changed

‎src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
5858
use Symfony\Component\Routing\DependencyInjection\AddExpressionLanguageProvidersPass;
5959
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
60+
use Symfony\Component\Runtime\SymfonyRuntime;
6061
use Symfony\Component\Scheduler\DependencyInjection\AddScheduleMessengerPass;
6162
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
6263
use Symfony\Component\Translation\DependencyInjection\DataCollectorTranslatorPass;
@@ -95,9 +96,16 @@ public function boot(): void
9596
{
9697
$_ENV['DOCTRINE_DEPRECATIONS'] = $_SERVER['DOCTRINE_DEPRECATIONS'] ??= 'trigger';
9798

98-
$handler = ErrorHandler::register(null, false);
99+
if (class_exists(SymfonyRuntime::class)) {
100+
$handler = set_error_handler('var_dump');
101+
restore_error_handler();
102+
} else {
103+
$handler = [ErrorHandler::register(null, false)];
104+
}
99105

100-
$this->container->get('debug.error_handler_configurator')->configure($handler);
106+
if (\is_array($handler) && $handler[0] instanceof ErrorHandler) {
107+
$this->container->get('debug.error_handler_configurator')->configure($handler[0]);
108+
}
101109

102110
if ($this->container->getParameter('kernel.http_method_override')) {
103111
Request::enableHttpMethodParameterOverride();

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"symfony/mime": "<6.4",
9393
"symfony/property-info": "<6.4",
9494
"symfony/property-access": "<6.4",
95+
"symfony/runtime": "<6.4.13|>=7.0,<7.1.6",
9596
"symfony/scheduler": "<6.4.4|>=7.0.0,<7.0.4",
9697
"symfony/serializer": "<6.4",
9798
"symfony/security-csrf": "<6.4",

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ public function run(?InputInterface $input = null, ?OutputInterface $output = nu
161161
}
162162
}
163163

164-
$this->configureIO($input, $output);
165-
166164
try {
165+
$this->configureIO($input, $output);
166+
167167
$exitCode = $this->doRun($input, $output);
168168
} catch (\Throwable $e) {
169169
if ($e instanceof \Exception && !$this->catchExceptions) {

‎src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public function __construct(?callable $exceptionHandler = null, bool|LoggerInter
4747
// BC with Symfony 5
4848
$webMode = null;
4949
}
50-
$handler = set_exception_handler('is_int');
50+
51+
$handler = set_exception_handler('var_dump');
5152
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
5253
restore_exception_handler();
5354

@@ -94,7 +95,7 @@ public function configure(?object $event = null): void
9495
}
9596
}
9697
if ($this->exceptionHandler) {
97-
$handler = set_exception_handler(static fn () => null);
98+
$handler = set_exception_handler('var_dump');
9899
$handler = \is_array($handler) ? $handler[0] : null;
99100
restore_exception_handler();
100101

‎src/Symfony/Component/HttpKernel/EventListener/ErrorListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/ErrorListener.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ public function onKernelException(ExceptionEvent $event): void
8484

8585
$throwable = $event->getThrowable();
8686

87-
if ($exceptionHandler = set_exception_handler(var_dump(...))) {
88-
restore_exception_handler();
89-
if (\is_array($exceptionHandler) && $exceptionHandler[0] instanceof ErrorHandler) {
90-
$throwable = $exceptionHandler[0]->enhanceError($event->getThrowable());
91-
}
87+
$exceptionHandler = set_exception_handler('var_dump');
88+
restore_exception_handler();
89+
90+
if (\is_array($exceptionHandler) && $exceptionHandler[0] instanceof ErrorHandler) {
91+
$throwable = $exceptionHandler[0]->enhanceError($event->getThrowable());
9292
}
9393

9494
$request = $this->duplicateRequest($throwable, $event->getRequest());

‎src/Symfony/Component/Runtime/GenericRuntime.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Runtime/GenericRuntime.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ public function __construct(array $options = [])
7171
if ($debug) {
7272
umask(0000);
7373
$_SERVER[$debugKey] = $_ENV[$debugKey] = '1';
74-
75-
if (false !== $errorHandler = ($options['error_handler'] ?? BasicErrorHandler::class)) {
76-
$errorHandler::register($debug);
77-
$options['error_handler'] = false;
78-
}
7974
} else {
8075
$_SERVER[$debugKey] = $_ENV[$debugKey] = '0';
8176
}
8277

78+
if (false !== $errorHandler = ($options['error_handler'] ?? BasicErrorHandler::class)) {
79+
$errorHandler::register($debug);
80+
$options['error_handler'] = false;
81+
}
82+
8383
$this->options = $options;
8484
}
8585

‎src/Symfony/Component/Runtime/Internal/BasicErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Runtime/Internal/BasicErrorHandler.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public static function register(bool $debug): void
3030
}
3131

3232
if (0 <= \ini_get('zend.assertions')) {
33-
ini_set('zend.assertions', 1);
34-
ini_set('assert.active', $debug);
35-
ini_set('assert.exception', 1);
33+
ini_set('zend.assertions', (int) $debug);
3634
}
35+
ini_set('assert.active', 1);
36+
ini_set('assert.exception', 1);
3737

3838
set_error_handler(new self());
3939
}

‎src/Symfony/Component/Runtime/Internal/SymfonyErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Runtime/Internal/SymfonyErrorHandler.php
+23-4Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,31 @@ class SymfonyErrorHandler
2424
{
2525
public static function register(bool $debug): void
2626
{
27-
BasicErrorHandler::register($debug);
27+
if (!class_exists(ErrorHandler::class)) {
28+
BasicErrorHandler::register($debug);
2829

29-
if (class_exists(ErrorHandler::class)) {
30+
return;
31+
}
32+
33+
error_reporting(-1);
34+
35+
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
36+
ini_set('display_errors', $debug);
37+
} elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
38+
// CLI - display errors only if they're not already logged to STDERR
39+
ini_set('display_errors', 1);
40+
}
41+
42+
if (0 <= \ini_get('zend.assertions')) {
43+
ini_set('zend.assertions', (int) $debug);
44+
}
45+
ini_set('assert.active', 1);
46+
ini_set('assert.exception', 1);
47+
48+
if ($debug) {
3049
DebugClassLoader::enable();
31-
restore_error_handler();
32-
ErrorHandler::register(new ErrorHandler(new BufferingLogger(), $debug));
3350
}
51+
52+
ErrorHandler::register(new ErrorHandler(new BufferingLogger(), $debug));
3453
}
3554
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.