Parcourir la source

Fix wrong serialization for commands that do not have arguments.

Daniele Alessandri il y a 13 ans
Parent
commit
0de4af07dd
1 fichiers modifiés avec 9 ajouts et 4 suppressions
  1. 9 4
      lib/Predis/Network/WebdisConnection.php

+ 9 - 4
lib/Predis/Network/WebdisConnection.php

@@ -129,14 +129,19 @@ class WebdisConnection implements IConnectionSingle {
     }
 
     public function executeCommand(ICommand $command) {
-        $commandId = $this->getCommandId($command);
-        $arguments = implode('/', array_map('urlencode', $command->getArguments()));
-
         $request = new HttpRequest($this->_webdisUrl, HttpRequest::METH_POST);
         if ($options = $this->getHttpOptions()) {
             $request->setOptions($options);
         }
-        $request->setBody("$commandId/$arguments.raw");
+
+        $commandId = $this->getCommandId($command);
+        if ($arguments = $command->getArguments()) {
+            $arguments = implode('/', array_map('urlencode', $arguments));
+            $request->setBody("$commandId/$arguments.raw");
+        }
+        else {
+            $request->setBody("$commandId.raw");
+        }
 
         $response = $request->send();
         phpiredis_reader_feed($this->_reader, $response->getBody());