Add normalizeVariadic to RPUSHX and LPUSHX commands (#1633)

* 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 <tillkruss@users.noreply.github.com>
This commit is contained in:
Denis
2026-02-12 00:07:39 +07:00
committed by GitHub
parent 8b9f882a43
commit 5d85628a11
5 changed files with 49 additions and 0 deletions
+1
View File
@@ -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)
+10
View File
@@ -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);
+10
View File
@@ -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);
@@ -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
*/
@@ -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
*/