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

Commit d8009e5

Browse files
Merge branch '2.7' into 2.8
* 2.7: Drop hirak/prestissimo 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: src/Symfony/Component/HttpKernel/Kernel.php
2 parents 40bc319 + 5fe2066 commit d8009e5

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
@@ -539,7 +539,7 @@ public function handleException($exception, array $error = null)
539539
}
540540
$type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
541541

542-
if ($this->loggedErrors & $type) {
542+
if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
543543
$e = array(
544544
'type' => $type,
545545
'file' => $exception->getFile(),
@@ -566,9 +566,9 @@ public function handleException($exception, array $error = null)
566566
} else {
567567
$message = 'Uncaught Exception: '.$exception->getMessage();
568568
}
569-
if ($this->loggedErrors & $e['type']) {
570-
$this->loggers[$e['type']][0]->log($this->loggers[$e['type']][1], $message, $e);
571-
}
569+
}
570+
if ($this->loggedErrors & $type) {
571+
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
572572
}
573573
if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
574574
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
@@ -484,6 +484,24 @@ public function testHandleFatalError()
484484
}
485485
}
486486

487+
/**
488+
* @requires PHP 7
489+
*/
490+
public function testHandleErrorException()
491+
{
492+
$exception = new \Error("Class 'Foo' not found");
493+
494+
$handler = new ErrorHandler();
495+
$handler->setExceptionHandler(function () use (&$args) {
496+
$args = func_get_args();
497+
});
498+
499+
$handler->handleException($exception);
500+
501+
$this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $args[0]);
502+
$this->assertSame("Attempted to load class \"Foo\" from the global namespace.\nDid you forget a \"use\" statement?", $args[0]->getMessage());
503+
}
504+
487505
public function testHandleFatalErrorOnHHVM()
488506
{
489507
try {

0 commit comments

Comments
 (0)