Skip to content

Commit 5fe98b5

Browse files
committed
Trim DSN config value
1 parent 8cff6d0 commit 5fe98b5

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## 0.8.5 - 2017-08-22
10+
### Fixed
11+
- `trim()` DSN value from config, to avoid issues with .env files on BitBucket (see https://github.com/getsentry/sentry-symfony/pull/21#issuecomment-323673938)
12+
913
## 0.8.4 - 2017-08-08
1014
### Fixed
1115
- Fix exception being thrown when both deprecated and new options are used.

src/Sentry/SentryBundle/DependencyInjection/Configuration.php

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public function getConfigTreeBuilder()
2323
{
2424
$treeBuilder = new TreeBuilder();
2525
$rootNode = $treeBuilder->root('sentry');
26+
$trimClosure = function ($str) {
27+
$value = trim($str);
28+
if ($value === '') {
29+
return null;
30+
}
31+
32+
return $value;
33+
};
2634

2735
$rootNode
2836
->children()
@@ -36,6 +44,10 @@ public function getConfigTreeBuilder()
3644
->defaultValue('%kernel.environment%')
3745
->end()
3846
->scalarNode('dsn')
47+
->beforeNormalization()
48+
->ifString()
49+
->then($trimClosure)
50+
->end()
3951
->defaultNull()
4052
->end()
4153
->arrayNode('options')

test/DependencyInjection/SentryExtensionTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,32 @@ public function test_that_it_uses_null_as_dsn_default_value()
194194
);
195195
}
196196

197+
/**
198+
* @dataProvider emptyDsnValueProvider
199+
*/
200+
public function test_that_it_ignores_empty_dsn_value($emptyDsn)
201+
{
202+
$container = $this->getContainer(
203+
array(
204+
static::CONFIG_ROOT => array(
205+
'dsn' => $emptyDsn,
206+
),
207+
)
208+
);
209+
210+
$this->assertNull($container->getParameter('sentry.dsn'));
211+
}
212+
213+
public function emptyDsnValueProvider()
214+
{
215+
return array(
216+
array(null),
217+
array(''),
218+
array(' '),
219+
array(' '),
220+
);
221+
}
222+
197223
public function test_that_it_uses_dsn_value()
198224
{
199225
$container = $this->getContainer(

0 commit comments

Comments
 (0)