From ca4c173e2f0c350309e536c832b766e2b299c5d2 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Wed, 14 Dec 2022 14:41:37 +0100 Subject: [PATCH] Fix config for replicated setups --- src/DependencyInjection/SncRedisExtension.php | 2 +- tests/DependencyInjection/SncRedisExtensionTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DependencyInjection/SncRedisExtension.php b/src/DependencyInjection/SncRedisExtension.php index 32f5b3fe..f18f02c4 100644 --- a/src/DependencyInjection/SncRedisExtension.php +++ b/src/DependencyInjection/SncRedisExtension.php @@ -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 = []; diff --git a/tests/DependencyInjection/SncRedisExtensionTest.php b/tests/DependencyInjection/SncRedisExtensionTest.php index 8861d48f..ca241483 100644 --- a/tests/DependencyInjection/SncRedisExtensionTest.php +++ b/tests/DependencyInjection/SncRedisExtensionTest.php @@ -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']);