Skip to content

Commit 938770b

Browse files
committed
Fix bug that triggers error when using both deprecated and new option keys
1 parent 70ecbbf commit 938770b

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Diff for: src/Sentry/SentryBundle/DependencyInjection/SentryExtension.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ private function checkConfigurationOnForInvalidSettings(array $config, Container
7171
}
7272

7373
// both are used
74-
if ($config[$option] !== $default && $config['options'][$option] !== $default) {
74+
if (
75+
$config[$option] !== $default
76+
&& $config['options'][$option] !== $default
77+
&& $config['options'][$option] !== $config[$option]
78+
) {
7579
$message = sprintf(
7680
'You are using both the deprecated option sentry.%s and the new sentry.options.%s, but values do not match. Drop the deprecated one or make the values identical.',
7781
$option,

Diff for: test/DependencyInjection/ExtensionTest.php renamed to test/DependencyInjection/SentryExtensionTest.php

+33-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Sentry\SentryBundle\DependencyInjection\SentryExtension;
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
77

8-
class ExtensionTest extends \PHPUnit_Framework_TestCase
8+
class SentryExtensionTest extends \PHPUnit_Framework_TestCase
99
{
1010
const CONFIG_ROOT = 'sentry';
1111

@@ -52,6 +52,38 @@ public function test_that_it_uses_app_path_value()
5252
);
5353
}
5454

55+
public function test_that_it_uses_both_new_and_deprecated_values()
56+
{
57+
$container = $this->getContainer(
58+
array(
59+
static::CONFIG_ROOT => array(
60+
'app_path' => 'sentry/app/path',
61+
'options' => array('app_path' => 'sentry/app/path'),
62+
),
63+
)
64+
);
65+
66+
$options = $container->getParameter('sentry.options');
67+
$this->assertSame(
68+
'sentry/app/path',
69+
$options['app_path']
70+
);
71+
}
72+
73+
public function test_that_throws_exception_if_new_and_deprecated_values_dont_match()
74+
{
75+
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
76+
77+
$this->getContainer(
78+
array(
79+
'app_path' => 'sentry/app/path',
80+
static::CONFIG_ROOT => array(
81+
'options' => array('app_path' => 'sentry/different/app/path'),
82+
),
83+
)
84+
);
85+
}
86+
5587
public function test_vendor_in_deprecated_default_excluded_paths()
5688
{
5789
$container = $this->getContainer();

0 commit comments

Comments
 (0)