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

Commitf66b853

Browse files
bug#39434 [Cache] Bugfix provide the correct host and port when throwing the exception (renan)
This PR was merged into the 5.3-dev branch.Discussion----------[Cache] Bugfix provide the correct host and port when throwing the exception| Q | A| ------------- | ---| Branch? | 5.x| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets | none| License | MIT| Doc PR | noneThe message before was including the result of the `getMasterAddrByName` call of which ended with:```Failed to retrieve master information from master name "mymaster" and address ":0".```Commits-------276bbb5 [Cache] Bugfix provide the correct host and port when throwing the exception
2 parents7c98ee1 +276bbb5 commitf66b853

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

‎src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ public function testInvalidDSNHasBothClusterAndSentinel()
4141
$dsn ='redis:?host[redis1]&host[redis2]&host[redis3]&redis_cluster=1&redis_sentinel=mymaster';
4242
RedisAdapter::createConnection($dsn);
4343
}
44+
45+
publicfunctiontestExceptionMessageWhenFailingToRetrieveMasterInformation()
46+
{
47+
$hosts =getenv('REDIS_SENTINEL_HOSTS');
48+
$firstHost =explode('',$hosts)[0];
49+
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
50+
$this->expectExceptionMessage('Failed to retrieve master information from master name "invalid-masterset-name" and address "'.$firstHost.'".');
51+
AbstractAdapter::createConnection('redis:?host['.str_replace('',']&host[',$hosts).']', ['redis_sentinel' =>'invalid-masterset-name']);
52+
}
4453
}

‎src/Symfony/Component/Cache/Traits/RedisTrait.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ public static function createConnection($dsn, array $options = [])
186186
if (isset($params['redis_sentinel'])) {
187187
$sentinel =new \RedisSentinel($host,$port,$params['timeout'], (string)$params['persistent_id'],$params['retry_interval'],$params['read_timeout']);
188188

189-
if (![$host,$port] =$sentinel->getMasterAddrByName($params['redis_sentinel'])) {
189+
if (!$address =$sentinel->getMasterAddrByName($params['redis_sentinel'])) {
190190
thrownewInvalidArgumentException(sprintf('Failed to retrieve master information from master name "%s" and address "%s:%d".',$params['redis_sentinel'],$host,$port));
191191
}
192+
193+
[$host,$port] =$address;
192194
}
193195

194196
try {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp