Skip to content
This repository was archived by the owner on Dec 9, 2023. It is now read-only.

Commit a5f488f

Browse files
Merge branch '2.8' into 3.0
* 2.8: Drop hirak/prestissimo bumped Symfony version to 2.8.7 updated VERSION for 2.8.6 updated CHANGELOG for 2.8.6 bumped Symfony version to 2.7.14 updated VERSION for 2.7.13 updated CHANGELOG for 2.7.13 bumped Symfony version to 2.3.42 [Debug] Fix fatal error handlers on PHP 7 updated VERSION for 2.3.41 update CONTRIBUTORS for 2.3.41 updated CHANGELOG for 2.3.41 Conflicts: CHANGELOG-2.3.md CHANGELOG-2.7.md CHANGELOG-3.0.md appveyor.yml src/Symfony/Component/HttpKernel/Kernel.php
2 parents a06d108 + d8009e5 commit a5f488f

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

ErrorHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ public function handleException($exception, array $error = null)
494494
}
495495
$type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
496496

497-
if ($this->loggedErrors & $type) {
497+
if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
498498
$e = array(
499499
'type' => $type,
500500
'file' => $exception->getFile(),
@@ -521,9 +521,9 @@ public function handleException($exception, array $error = null)
521521
} else {
522522
$message = 'Uncaught Exception: '.$exception->getMessage();
523523
}
524-
if ($this->loggedErrors & $e['type']) {
525-
$this->loggers[$e['type']][0]->log($this->loggers[$e['type']][1], $message, $e);
526-
}
524+
}
525+
if ($this->loggedErrors & $type) {
526+
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
527527
}
528528
if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
529529
foreach ($this->getFatalErrorHandlers() as $handler) {

Exception/FatalThrowableError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(\Throwable $e)
2727
$message = 'Type error: '.$e->getMessage();
2828
$severity = E_RECOVERABLE_ERROR;
2929
} else {
30-
$message = 'Fatal error: '.$e->getMessage();
30+
$message = $e->getMessage();
3131
$severity = E_ERROR;
3232
}
3333

Tests/ErrorHandlerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,24 @@ public function testHandleFatalError()
448448
}
449449
}
450450

451+
/**
452+
* @requires PHP 7
453+
*/
454+
public function testHandleErrorException()
455+
{
456+
$exception = new \Error("Class 'Foo' not found");
457+
458+
$handler = new ErrorHandler();
459+
$handler->setExceptionHandler(function () use (&$args) {
460+
$args = func_get_args();
461+
});
462+
463+
$handler->handleException($exception);
464+
465+
$this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $args[0]);
466+
$this->assertSame("Attempted to load class \"Foo\" from the global namespace.\nDid you forget a \"use\" statement?", $args[0]->getMessage());
467+
}
468+
451469
public function testHandleFatalErrorOnHHVM()
452470
{
453471
try {

0 commit comments

Comments
 (0)