Skip to content

Commit f99b971

Browse files
authored
[Sqs] Allow array-based DSN configuration
I encountered a problem with using DSN-based configuration in Symfony 4, where the 'dsn' value was always being passed as an array key. The constructor did not properly handle this, and the primary symptom of this was a constant complaint that the 'region' was not set, even though it was present in the DSN.
1 parent 9c83fa0 commit f99b971

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎pkg/sqs/SqsConnectionFactory.php‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,18 @@ public function __construct($config = 'sqs:')
3939
{
4040
if (empty($config) || 'sqs:' === $config) {
4141
$config = [];
42-
} elseif (is_string($config)) {
42+
}
43+
44+
if (is_string($config)) {
4345
$config = $this->parseDsn($config);
44-
} elseif (is_array($config)) {
45-
} else {
46-
throw new \LogicException('The config must be either an array of options, a DSN string or null');
46+
}
47+
48+
if (!is_array($config)) {
49+
throw new \LogicException('The config must be either an array of options, a DSN string, or null');
50+
}
51+
52+
if (count($config) == 1 && array_key_exists('dsn', $config)) {
53+
$config = $this->parseDsn($config['dsn']);
4754
}
4855

4956
$this->config = array_replace($this->defaultConfig(), $config);

0 commit comments

Comments
 (0)