From 5d85628a117470c90f72b3280cb686b0a7f97ff2 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 12 Feb 2026 00:07:39 +0700 Subject: [PATCH] Add normalizeVariadic to RPUSHX and LPUSHX commands (#1633) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add normalizeVariadic to RPUSHX and LPUSHX commands RPUSHX and LPUSHX commands were missing the setArguments method with normalizeVariadic call, unlike their RPUSH and LPUSH counterparts. This caused errors when passing values as a single array argument (e.g. $client->rpushx('key', ['val1', 'val2'])). Fixes #1504 * Update CHANGELOG.md with RPUSHX/LPUSHX variadic fix (#1633) * Fix variadic arguments normalization for [L|R]PUSHX --------- Co-authored-by: Till Krüss --- CHANGELOG.md | 1 + src/Command/Redis/LPUSHX.php | 10 ++++++++++ src/Command/Redis/RPUSHX.php | 10 ++++++++++ tests/Predis/Command/Redis/LPUSHX_Test.php | 14 ++++++++++++++ tests/Predis/Command/Redis/RPUSHX_Test.php | 14 ++++++++++++++ 5 files changed, 49 insertions(+) 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 */