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

Commit87dcda8

Browse files
bug#21311 [Debug] Fix fatal error when changing ErrorHandler loggers if an exception is buffered (skalpa)
This PR was merged into the 3.2 branch.Discussion----------[Debug] Fix fatal error when changing ErrorHandler loggers if an exception is buffered| Q | A| ------------- | ---| Branch? | 3.2| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#21304| License | MIT| Doc PR | -Prevents a fatal error when setting a new logger if the bootstrapping logger buffered an exception that does not extend `ErrorException`.@nicolas-grekas The faulty behaviour was added by8f24549, so this PR is against 3.2 and not 2.8.Commits-------a6527f8 [Debug] Fix fatal error when changing ErrorHandler loggers if an exception is buffered
2 parents7a90fcb +a6527f8 commit87dcda8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function setLoggers(array $loggers)
225225

226226
if ($flush) {
227227
foreach ($this->bootstrappingLogger->cleanLogs()as$log) {
228-
$type =$log[2]['exception']->getSeverity();
228+
$type =$log[2]['exception']instanceof \ErrorException ?$log[2]['exception']->getSeverity() :E_ERROR;
229229
if (!isset($flush[$type])) {
230230
$this->bootstrappingLogger->log($log[0],$log[1],$log[2]);
231231
}elseif ($this->loggers[$type][0]) {

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,25 @@ public function testBootstrappingLogger()
417417
$handler->setLoggers(array(E_DEPRECATED =>array($mockLogger, LogLevel::WARNING)));
418418
}
419419

420+
publicfunctiontestSettingLoggerWhenExceptionIsBuffered()
421+
{
422+
$bootLogger =newBufferingLogger();
423+
$handler =newErrorHandler($bootLogger);
424+
425+
$exception =new \Exception('Foo message');
426+
427+
$mockLogger =$this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
428+
$mockLogger->expects($this->once())
429+
->method('log')
430+
->with(LogLevel::CRITICAL,'Uncaught Exception: Foo message',array('exception' =>$exception));
431+
432+
$handler->setExceptionHandler(function ()use ($handler,$mockLogger) {
433+
$handler->setDefaultLogger($mockLogger);
434+
});
435+
436+
$handler->handleException($exception);
437+
}
438+
420439
publicfunctiontestHandleFatalError()
421440
{
422441
try {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp