Skip to content

Commit cf8f2bf

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

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
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)

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)