Skip to content

Commit

Permalink
Fix empty or null DSN not disabling Sentry (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
ste93cry authored Mar 3, 2021
1 parent b4ce112 commit 8349e99
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 37 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 1 addition & 6 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 0 additions & 10 deletions tests/DependencyInjection/Fixtures/php/empty_dsn.php

This file was deleted.

10 changes: 0 additions & 10 deletions tests/DependencyInjection/Fixtures/xml/empty_dsn.xml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/DependencyInjection/Fixtures/yml/empty_dsn.yml

This file was deleted.

8 changes: 0 additions & 8 deletions tests/DependencyInjection/SentryExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 8349e99

Please sign in to comment.