Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb77a1e2

Browse files
[Debug] Fix fatal error handlers on PHP 7
1 parent60bf201 commitb77a1e2

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

‎src/Symfony/Component/Debug/ErrorHandler.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ public function handleException($exception, array $error = null)
469469
}
470470
$type =$exceptioninstanceof FatalErrorException ?$exception->getSeverity() :E_ERROR;
471471

472-
if ($this->loggedErrors &$type) {
472+
if (($this->loggedErrors &$type) ||$exceptioninstanceof FatalThrowableError) {
473473
$e =array(
474474
'type' =>$type,
475475
'file' =>$exception->getFile(),
@@ -496,9 +496,9 @@ public function handleException($exception, array $error = null)
496496
}else {
497497
$message ='Uncaught Exception:'.$exception->getMessage();
498498
}
499-
if ($this->loggedErrors &$e['type']) {
500-
$this->loggers[$e['type']][0]->log($this->loggers[$e['type']][1],$message,$e);
501-
}
499+
}
500+
if($this->loggedErrors &$type) {
501+
$this->loggers[$type][0]->log($this->loggers[$type][1],$message,$e);
502502
}
503503
if ($exceptioninstanceof FatalErrorException && !$exceptioninstanceof OutOfMemoryException &&$error) {
504504
foreach ($this->getFatalErrorHandlers()as$handler) {

‎src/Symfony/Component/Debug/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

‎src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,24 @@ public function testHandleFatalError()
413413
}
414414
}
415415

416+
/**
417+
* @requires PHP 7
418+
*/
419+
publicfunctiontestHandleErrorException()
420+
{
421+
$exception =new \Error("Class 'Foo' not found");
422+
423+
$handler =newErrorHandler();
424+
$handler->setExceptionHandler(function ()use (&$args) {
425+
$args =func_get_args();
426+
});
427+
428+
$handler->handleException($exception);
429+
430+
$this->assertInstanceOf('Symfony\Component\\Debug\\Exception\\ClassNotFoundException',$args[0]);
431+
$this->assertSame("Attempted to load class\"Foo\" from the global namespace.\nDid you forget a\"use\" statement?",$args[0]->getMessage());
432+
}
433+
416434
publicfunctiontestHandleFatalErrorOnHHVM()
417435
{
418436
try {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp