From 188dc6bf62754bdc5097caeba1f2acdc41b655a7 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Tue, 24 May 2016 21:34:44 +0200 Subject: [PATCH] Improve detection of STORE in SORT command arguments. --- src/Command/Processor/KeyPrefixProcessor.php | 2 +- src/Replication/ReplicationStrategy.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php index f982a8fe..0edb2142 100644 --- a/src/Command/Processor/KeyPrefixProcessor.php +++ b/src/Command/Processor/KeyPrefixProcessor.php @@ -338,7 +338,7 @@ class KeyPrefixProcessor implements ProcessorInterface if (($count = count($arguments)) > 1) { for ($i = 1; $i < $count; ++$i) { - switch ($arguments[$i]) { + switch (strtoupper($arguments[$i])) { case 'BY': case 'STORE': $arguments[$i] = "$prefix{$arguments[++$i]}"; diff --git a/src/Replication/ReplicationStrategy.php b/src/Replication/ReplicationStrategy.php index 0b769405..454f1caa 100644 --- a/src/Replication/ReplicationStrategy.php +++ b/src/Replication/ReplicationStrategy.php @@ -100,8 +100,18 @@ class ReplicationStrategy protected function isSortReadOnly(CommandInterface $command) { $arguments = $command->getArguments(); + $argc = count($arguments); - return ($c = count($arguments)) === 1 ? true : $arguments[$c - 2] !== 'STORE'; + if ($argc > 1) { + for ($i = 1; $i < $argc; $i++) { + $argument = strtoupper($arguments[$i]); + if ($argument === 'STORE') { + return false; + } + } + } + + return true; } /**