diff --git a/CHANGELOG.md b/CHANGELOG.md index 0825ee2c..2d14e91e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## Unreleased -- Add `kernel.project_dir` to `prefixes` default value to trim paths to the project root (#434) +- Add `kernel.project_dir` to `prefixes` default value to trim paths to the project root (#434) +- Fix `null`, `false` or empty value not disabling Sentry (#454) ## 4.0.1 (2021-01-26) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index e70f4a9c..5db93fd2 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -29,12 +29,7 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode ->children() ->scalarNode('dsn') - ->beforeNormalization() - ->ifTrue(static function ($value): bool { - return empty($value) || (\is_string($value) && '' === trim($value)); - }) - ->thenUnset() - ->end() + ->info('If this value is not provided, the SDK will try to read it from the SENTRY_DSN environment variable. If that variable also does not exist, the SDK will just not send any events.') ->end() ->booleanNode('register_error_listener')->defaultTrue()->end() ->arrayNode('options') diff --git a/tests/DependencyInjection/Fixtures/php/empty_dsn.php b/tests/DependencyInjection/Fixtures/php/empty_dsn.php deleted file mode 100644 index c7ae4027..00000000 --- a/tests/DependencyInjection/Fixtures/php/empty_dsn.php +++ /dev/null @@ -1,10 +0,0 @@ -loadFromExtension('sentry', [ - 'dsn' => ' ', -]); diff --git a/tests/DependencyInjection/Fixtures/xml/empty_dsn.xml b/tests/DependencyInjection/Fixtures/xml/empty_dsn.xml deleted file mode 100644 index 2f6a61c0..00000000 --- a/tests/DependencyInjection/Fixtures/xml/empty_dsn.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/tests/DependencyInjection/Fixtures/yml/empty_dsn.yml b/tests/DependencyInjection/Fixtures/yml/empty_dsn.yml deleted file mode 100644 index b79f919d..00000000 --- a/tests/DependencyInjection/Fixtures/yml/empty_dsn.yml +++ /dev/null @@ -1,2 +0,0 @@ -sentry: - dsn: ' ' diff --git a/tests/DependencyInjection/SentryExtensionTest.php b/tests/DependencyInjection/SentryExtensionTest.php index 6c848869..3d73facd 100644 --- a/tests/DependencyInjection/SentryExtensionTest.php +++ b/tests/DependencyInjection/SentryExtensionTest.php @@ -236,14 +236,6 @@ public function testClentIsCreatedFromOptions(): void $this->assertEquals($methodCalls[4][1][0]->getArgument(0), new Reference('sentry.client.options')); } - public function testEmptyDsnIsTreatedAsIfItWasUnset(): void - { - $container = $this->createContainerFromFixture('empty_dsn'); - $optionsDefinition = $container->getDefinition('sentry.client.options'); - - $this->assertArrayNotHasKey('dsn', $optionsDefinition->getArgument(0)); - } - public function testErrorTypesOptionIsParsedFromStringToIntegerValue(): void { $container = $this->createContainerFromFixture('error_types');