Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commitab24fb9

Browse files
bug#37269 [Lock][Messenger] Fix precedence of DSN options for 5.1 (jderusse)
This PR was squashed before being merged into the 5.1 branch.Discussion----------[Lock][Messenger] Fix precedence of DSN options for 5.1| Q | A| ------------- | ---| Branch? | 5.1| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |#37218 (comment)| License | MIT| Doc PR | N/AThis PR fix précédence of DSN options over constructor options in all component on branch 5.1Commits-------9670e9f [Lock][Messenger] Fix precedence of DSN options for 5.1
2 parents38c0971 +9670e9f commitab24fb9

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ 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;
124-
$this->options['database'] =$this->options['database'] ??ltrim($parsedUrl['path'] ??'','/') ?:null;
123+
$this->options['collection'] =$query['collection'] ??$this->options['collection'] ??null;
124+
$this->options['database'] =ltrim($parsedUrl['path'] ??'','/') ?:$this->options['database'] ??null;
125125
if (null ===$this->options['database']) {
126126
thrownewInvalidArgumentException(sprintf('"%s()" requires the "database" in the URI path or option when constructing with a URI.',__METHOD__));
127127
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ public function provideConstructorArgs()
121121
yield ['mongodb://localhost/', ['database' =>'test','collection' =>'lock']];
122122
}
123123

124+
publicfunctiontestDsnPrecedence()
125+
{
126+
$client =self::getMongoClient();
127+
128+
$store =newMongoDbStore('mongodb://localhost/test_dsn?collection=lock_dns', ['collection' =>'lock_option','database' =>'test_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+
$this->assertSame('test_dsn',$options['database']);
135+
}
136+
124137
/**
125138
* @dataProvider provideInvalidConstructorArgs
126139
*/

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public function testFromDsn()
7070
);
7171
}
7272

73+
publicfunctiontestDsnPrecedence()
74+
{
75+
$httpClient =$this->getMockBuilder(HttpClientInterface::class)->getMock();
76+
$this->assertEquals(
77+
newConnection(['queue_name' =>'queue_dsn'],newSqsClient(['region' =>'us-east-2','accessKeyId' =>'key_dsn','accessKeySecret' =>'secret_dsn'],null,$httpClient)),
78+
Connection::fromDsn('sqs://key_dsn:secret_dsn@default/queue_dsn?region=us-east-2', ['region' =>'eu-west-3','queue_name' =>'queue_options','access_key' =>'key_option','secret_key' =>'secret_option'],$httpClient)
79+
);
80+
}
81+
7382
publicfunctiontestFromDsnWithRegion()
7483
{
7584
$httpClient =$this->getMockBuilder(HttpClientInterface::class)->getMock();

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
9494
if (isset($parsedUrl['query'])) {
9595
parse_str($parsedUrl['query'],$query);
9696
}
97-
97+
$options =$query +$options +self::DEFAULT_OPTIONS;
9898
$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']),
99+
'buffer_size' => (int)$options['buffer_size'],
100+
'wait_time' => (int)$options['wait_time'],
101+
'poll_timeout' =>$options['poll_timeout'],
102+
'visibility_timeout' =>$options['visibility_timeout'],
103+
'auto_setup' => (bool)$options['auto_setup'],
104104
];
105105

106106
$clientConfiguration = [
107-
'region' =>$options['region'] ?? ($query['region'] ??self::DEFAULT_OPTIONS['region']),
108-
'accessKeyId' =>$options['access_key'] ?? (urldecode($parsedUrl['user'] ??'') ?:self::DEFAULT_OPTIONS['access_key']),
109-
'accessKeySecret' =>$options['secret_key'] ?? (urldecode($parsedUrl['pass'] ??'') ?:self::DEFAULT_OPTIONS['secret_key']),
107+
'region' =>$options['region'],
108+
'accessKeyId' =>urldecode($parsedUrl['user'] ??'') ?:$options['access_key'] ??self::DEFAULT_OPTIONS['access_key'],
109+
'accessKeySecret' =>urldecode($parsedUrl['pass'] ??'') ?:$options['secret_key'] ??self::DEFAULT_OPTIONS['secret_key'],
110110
];
111111
unset($query['region']);
112112

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp