Skip to content

Commit 354bf9f

Browse files
committed
Fix fatal errors logged twice on Symfony 3.4
1 parent cbd486c commit 354bf9f

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix fatal errors logged twice on Symfony `3.4` (#570)
6+
57
## 4.2.4 (2021-10-20)
68

79
- Add return typehints to the methods of the `SentryExtension` class to prepare for Symfony 6 (#563)

phpstan-baseline.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ parameters:
1010
count: 1
1111
path: src/DependencyInjection/Configuration.php
1212

13+
-
14+
message: "#^Class Symfony\\\\Component\\\\Debug\\\\Exception\\\\FatalErrorException not found\\.$#"
15+
count: 1
16+
path: src/DependencyInjection/SentryExtension.php
17+
1318
-
1419
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
1520
count: 1
@@ -55,6 +60,11 @@ parameters:
5560
count: 1
5661
path: src/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnection.php
5762

63+
-
64+
message: "#^Class Symfony\\\\Component\\\\Debug\\\\Exception\\\\FatalErrorException not found\\.$#"
65+
count: 1
66+
path: tests/DependencyInjection/SentryExtensionTest.php
67+
5868
-
5969
message: "#^Class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Client not found\\.$#"
6070
count: 1

psalm-baseline.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.10.0@916b098b008f6de4543892b1e0651c1c3b92cbfa">
2+
<files psalm-version="4.11.1@e33492398bd4e5e2ab60e331d445979bd83feecd">
3+
<file src="src/DependencyInjection/SentryExtension.php">
4+
<UndefinedClass occurrences="1">
5+
<code>FatalErrorException</code>
6+
</UndefinedClass>
7+
</file>
38
<file src="src/EventListener/ConsoleCommandListener.php">
49
<InvalidExtendClass occurrences="1">
510
<code>ConsoleListener</code>

src/DependencyInjection/SentryExtension.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Symfony\Bundle\TwigBundle\TwigBundle;
3232
use Symfony\Component\Cache\CacheItem;
3333
use Symfony\Component\Config\FileLocator;
34+
use Symfony\Component\Debug\Exception\FatalErrorException;
3435
use Symfony\Component\DependencyInjection\ContainerBuilder;
3536
use Symfony\Component\DependencyInjection\Definition;
3637
use Symfony\Component\DependencyInjection\Loader;
@@ -273,7 +274,14 @@ private function configureErrorListenerIntegration(array $integrations, bool $re
273274
// Prepend this integration to the beginning of the array so that
274275
// we can save some performance by skipping the rest of the integrations
275276
// if the error must be ignored
276-
array_unshift($integrations, new Definition(IgnoreErrorsIntegration::class, [['ignore_exceptions' => [FatalError::class]]]));
277+
array_unshift($integrations, new Definition(IgnoreErrorsIntegration::class, [
278+
[
279+
'ignore_exceptions' => [
280+
FatalError::class,
281+
FatalErrorException::class,
282+
],
283+
],
284+
]));
277285
}
278286

279287
return $integrations;

tests/DependencyInjection/SentryExtensionTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Sentry\Transport\TransportFactoryInterface;
3030
use Symfony\Bundle\TwigBundle\TwigBundle;
3131
use Symfony\Component\Console\ConsoleEvents;
32+
use Symfony\Component\Debug\Exception\FatalErrorException;
3233
use Symfony\Component\DependencyInjection\ContainerBuilder;
3334
use Symfony\Component\DependencyInjection\Definition;
3435
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
@@ -185,7 +186,14 @@ public function testClientIsCreatedFromOptions(): void
185186
$optionsDefinition = $container->getDefinition('sentry.client.options');
186187
$expectedOptions = [
187188
'integrations' => [
188-
new Definition(IgnoreErrorsIntegration::class, [['ignore_exceptions' => [FatalError::class]]]),
189+
new Definition(IgnoreErrorsIntegration::class, [
190+
[
191+
'ignore_exceptions' => [
192+
FatalError::class,
193+
FatalErrorException::class,
194+
],
195+
],
196+
]),
189197
new Reference('App\\Sentry\\Integration\\FooIntegration'),
190198
],
191199
'default_integrations' => false,

0 commit comments

Comments
 (0)