Skip to content

Commit

Permalink
Fix config for replicated setups
Browse files Browse the repository at this point in the history
  • Loading branch information
HypeMC authored and ostrolucky committed Dec 16, 2022
1 parent feec42e commit ca4c173
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/DependencyInjection/SncRedisExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function loadPredisClient(array $client, ContainerBuilder $container): v
$container->setDefinition($optionId, $optionDef);
$clientDef = new Definition((string) $container->getParameter('snc_redis.client.class'));
$clientDef->addTag('snc_redis.client', ['alias' => $client['alias']]);
if ($connectionCount === 1 && !isset($client['options']['cluster'], $client['options']['replication'])) {
if ($connectionCount === 1 && !isset($client['options']['cluster']) && !isset($client['options']['replication'])) {
$clientDef->addArgument(new Reference(sprintf('snc_redis.connection.%s_parameters.%s', $connectionAliases[0], $client['alias'])));
} else {
$connections = [];
Expand Down
4 changes: 2 additions & 2 deletions tests/DependencyInjection/SncRedisExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ public function testSingleSentinelOption(): void
$this->assertEquals('sentinel', $options['replication']);
$this->assertEquals('mymaster', $options['service']);
$parameters = $container->getDefinition('snc_redis.default')->getArgument(0);
$this->assertEquals('snc_redis.connection.default_parameters.default', (string) $parameters);
$masterParameters = $container->getDefinition((string) $parameters)->getArgument(0);
$this->assertEquals('snc_redis.connection.default_parameters.default', (string) $parameters[0]);
$masterParameters = $container->getDefinition((string) $parameters[0])->getArgument(0);
$this->assertEquals('sentinel', $masterParameters['replication']);
$this->assertEquals('mymaster', $masterParameters['service']);
$this->assertIsArray($masterParameters['parameters']);
Expand Down

0 comments on commit ca4c173

Please sign in to comment.