diff --git a/CHANGELOG.md b/CHANGELOG.md index 07364bb5..6ee0df53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased ### Fixed +- Fixed `[L|R]PUSHX` variadic arguments normalization (#1633) - Fixed wrong `@param` annotation in `Parameters` (#1614) - Make `ZRANDMEMBER` prefixable (#1621) - Improve connection handshake by pipelining commands (#1622) diff --git a/src/Command/Redis/LPUSHX.php b/src/Command/Redis/LPUSHX.php index bbbc6a9d..b8d09764 100644 --- a/src/Command/Redis/LPUSHX.php +++ b/src/Command/Redis/LPUSHX.php @@ -27,6 +27,16 @@ class LPUSHX extends RedisCommand return 'LPUSHX'; } + /** + * {@inheritdoc} + */ + public function setArguments(array $arguments) + { + $arguments = self::normalizeVariadic($arguments); + + parent::setArguments($arguments); + } + public function prefixKeys($prefix) { $this->applyPrefixForFirstArgument($prefix); diff --git a/src/Command/Redis/RPUSHX.php b/src/Command/Redis/RPUSHX.php index aadb92be..ac39bd16 100644 --- a/src/Command/Redis/RPUSHX.php +++ b/src/Command/Redis/RPUSHX.php @@ -27,6 +27,16 @@ class RPUSHX extends RedisCommand return 'RPUSHX'; } + /** + * {@inheritdoc} + */ + public function setArguments(array $arguments) + { + $arguments = self::normalizeVariadic($arguments); + + parent::setArguments($arguments); + } + public function prefixKeys($prefix) { $this->applyPrefixForFirstArgument($prefix); diff --git a/tests/Predis/Command/Redis/LPUSHX_Test.php b/tests/Predis/Command/Redis/LPUSHX_Test.php index 098f63cf..8fccf768 100644 --- a/tests/Predis/Command/Redis/LPUSHX_Test.php +++ b/tests/Predis/Command/Redis/LPUSHX_Test.php @@ -50,6 +50,20 @@ class LPUSHX_Test extends PredisCommandTestCase $this->assertSame($expected, $command->getArguments()); } + /** + * @group disconnected + */ + public function testFilterArgumentsValuesAsSingleArray(): void + { + $arguments = ['key', ['value1', 'value2', 'value3']]; + $expected = ['key', 'value1', 'value2', 'value3']; + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + /** * @group disconnected */ diff --git a/tests/Predis/Command/Redis/RPUSHX_Test.php b/tests/Predis/Command/Redis/RPUSHX_Test.php index 0bfb2dca..d85468eb 100644 --- a/tests/Predis/Command/Redis/RPUSHX_Test.php +++ b/tests/Predis/Command/Redis/RPUSHX_Test.php @@ -50,6 +50,20 @@ class RPUSHX_Test extends PredisCommandTestCase $this->assertSame($expected, $command->getArguments()); } + /** + * @group disconnected + */ + public function testFilterArgumentsValuesAsSingleArray(): void + { + $arguments = ['key', ['value1', 'value2', 'value3']]; + $expected = ['key', 'value1', 'value2', 'value3']; + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + /** * @group disconnected */