bug #41760 [ErrorHandler] fix handling buffered SilencedErrorContext (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] fix handling buffered SilencedErrorContext

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #41745
| License       | MIT
| Doc PR        | -

Commits
-------

07407c74ca [ErrorHandler] fix handling buffered SilencedErrorContext
This commit is contained in:
Nicolas Grekas 2021-06-24 09:57:22 +02:00
commit 119b3ec26e
2 changed files with 8 additions and 3 deletions

View File

@ -17,7 +17,7 @@
$status = 'warning';
} else {
$severity = 0;
if (($exception = $log['context']['exception'] ?? null) instanceof \ErrorException) {
if (($exception = $log['context']['exception'] ?? null) instanceof \ErrorException || $exception instanceof \Symfony\Component\ErrorHandler\Exception\SilencedErrorContext) {
$severity = $exception->getSeverity();
}
$status = \E_DEPRECATED === $severity || \E_USER_DEPRECATED === $severity ? 'warning' : 'normal';

View File

@ -11,14 +11,19 @@
namespace Symfony\Component\ErrorHandler;
use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
/**
* @internal
*/
class ThrowableUtils
{
public static function getSeverity(\Throwable $throwable): int
/**
* @param SilencedErrorContext|\Throwable
*/
public static function getSeverity($throwable): int
{
if ($throwable instanceof \ErrorException) {
if ($throwable instanceof \ErrorException || $throwable instanceof SilencedErrorContext) {
return $throwable->getSeverity();
}