Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 85fff57

Browse filesBrowse files
committed
Fix precendence in 5.0
1 parent 86c79ce commit 85fff57
Copy full SHA for 85fff57

File tree

4 files changed

+29
-7
lines changed
Filter options

4 files changed

+29
-7
lines changed

‎src/Symfony/Component/Lock/Store/MongoDbStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/MongoDbStore.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function __construct($mongo, array $options = [], float $initialTtl = 300
120120
if (isset($parsedUrl['query'])) {
121121
parse_str($parsedUrl['query'], $query);
122122
}
123-
$this->options['collection'] = $this->options['collection'] ?? $query['collection'] ?? null;
123+
$this->options['collection'] = $query['collection'] ?? $this->options['collection'] ?? null;
124124
$this->options['database'] = $this->options['database'] ?? ltrim($parsedUrl['path'] ?? '', '/') ?: null;
125125
if (null === $this->options['database']) {
126126
throw new InvalidArgumentException(sprintf('"%s()" requires the "database" in the URI path or option when constructing with a URI.', __METHOD__));

‎src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ public function provideConstructorArgs()
121121
yield ['mongodb://localhost/', ['database' => 'test', 'collection' => 'lock']];
122122
}
123123

124+
public function testDsnPrecedence()
125+
{
126+
$client = self::getMongoClient();
127+
128+
$store = new MongoDbStore('mongodb://localhost/test?collection=lock_dns', ['collection' => 'lock_option']);
129+
$r = new \ReflectionObject($store);
130+
$p = $r->getProperty('options');
131+
$p->setAccessible(true);
132+
$options = $p->getValue($store);
133+
$this->assertSame('lock_dns', $options['collection']);
134+
}
135+
124136
/**
125137
* @dataProvider provideInvalidConstructorArgs
126138
*/

‎src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public function testFromDsn()
7070
);
7171
}
7272

73+
public function testDsnPrecedence()
74+
{
75+
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
76+
$this->assertEquals(
77+
new Connection(['queue_name' => 'queue_dns'], new SqsClient(['region' => 'eu-west-3', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
78+
Connection::fromDsn('sqs://default/queue?region=us-west-3', ['region' => 'eu-west-2'], $httpClient)
79+
);
80+
}
81+
7382
public function testFromDsnWithRegion()
7483
{
7584
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();

‎src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,18 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
9494
if (isset($parsedUrl['query'])) {
9595
parse_str($parsedUrl['query'], $query);
9696
}
97+
$options = $options + $query + self::DEFAULT_OPTIONS;
9798

9899
$configuration = [
99-
'buffer_size' => $options['buffer_size'] ?? (int) ($query['buffer_size'] ?? self::DEFAULT_OPTIONS['buffer_size']),
100-
'wait_time' => $options['wait_time'] ?? (int) ($query['wait_time'] ?? self::DEFAULT_OPTIONS['wait_time']),
101-
'poll_timeout' => $options['poll_timeout'] ?? ($query['poll_timeout'] ?? self::DEFAULT_OPTIONS['poll_timeout']),
102-
'visibility_timeout' => $options['visibility_timeout'] ?? ($query['visibility_timeout'] ?? self::DEFAULT_OPTIONS['visibility_timeout']),
103-
'auto_setup' => $options['auto_setup'] ?? (bool) ($query['auto_setup'] ?? self::DEFAULT_OPTIONS['auto_setup']),
100+
'buffer_size' => (int) $options['buffer_size'],
101+
'wait_time' => (int) $options['wait_time'],
102+
'poll_timeout' => $options['poll_timeout'],
103+
'visibility_timeout' => $options['visibility_timeout'],
104+
'auto_setup' => (bool) $options['auto_setup'],
104105
];
105106

106107
$clientConfiguration = [
107-
'region' => $options['region'] ?? ($query['region'] ?? self::DEFAULT_OPTIONS['region']),
108+
'region' => $options['region'],
108109
'accessKeyId' => $options['access_key'] ?? (urldecode($parsedUrl['user'] ?? '') ?: self::DEFAULT_OPTIONS['access_key']),
109110
'accessKeySecret' => $options['secret_key'] ?? (urldecode($parsedUrl['pass'] ?? '') ?: self::DEFAULT_OPTIONS['secret_key']),
110111
];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.