From 5e18e91ffc4e21f781bab2c028e7f51c4883bb8e Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:46:25 +0300 Subject: [PATCH] fix(commands): Fixed wrong command API call on prefix processing (#1554) * fix(commands): Fixed wrong command API call on prefix processing * Updated CHANGELOG.md * Updated test case --- CHANGELOG.md | 1 + src/Command/PrefixableCommand.php | 4 ++-- tests/Predis/Command/Redis/XADD_Test.php | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e6df707..e6c57122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Fixed return type for `ZCOUNT` to be `int` (#1547) - fix(stream): Fixed throwing `CommunicationException` when stream is EOF (#1548) - Removed automatic `conn_uid` parameter assignment (#1552) +- fix(commands): Fixed wrong command API call on prefix processing (#1554) ## v3.0.1 (2025-05-16) ### Fixed diff --git a/src/Command/PrefixableCommand.php b/src/Command/PrefixableCommand.php index f531f6d4..cf741513 100644 --- a/src/Command/PrefixableCommand.php +++ b/src/Command/PrefixableCommand.php @@ -32,7 +32,7 @@ abstract class PrefixableCommand extends Command implements PrefixableCommandInt */ public function applyPrefixForAllArguments(string $prefix): void { - $this->setArguments( + $this->setRawArguments( array_map(static function ($key) use ($prefix) { return $prefix . $key; }, $this->getArguments()) @@ -49,7 +49,7 @@ abstract class PrefixableCommand extends Command implements PrefixableCommandInt { $arguments = $this->getArguments(); $arguments[0] = $prefix . $arguments[0]; - $this->setArguments($arguments); + $this->setRawArguments($arguments); } /** diff --git a/tests/Predis/Command/Redis/XADD_Test.php b/tests/Predis/Command/Redis/XADD_Test.php index 182c3971..6fc0222c 100644 --- a/tests/Predis/Command/Redis/XADD_Test.php +++ b/tests/Predis/Command/Redis/XADD_Test.php @@ -39,9 +39,9 @@ class XADD_Test extends PredisCommandTestCase { /** @var PrefixableCommand $command */ $command = $this->getCommand(); - $actualArguments = ['arg1', 'arg2', 'arg3', 'arg4']; + $actualArguments = ['key', ['entry' => 'value']]; $prefix = 'prefix:'; - $expectedArguments = ['prefix:arg1', '*']; + $expectedArguments = ['prefix:key', '*', 'entry', 'value']; $command->setArguments($actualArguments); $command->prefixKeys($prefix);