Kaynağa Gözat

Handle aborted MULTI/EXEC transactions.

Daniele Alessandri 15 yıl önce
ebeveyn
işleme
ac2b718387
1 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  1. 7 4
      lib/Predis.php

+ 7 - 4
lib/Predis.php

@@ -3,6 +3,7 @@ namespace Predis;
 
 class PredisException extends \Exception { }
 class ClientException extends PredisException { }                   // Client-side errors
+class AbortedMultiExec extends PredisException { }                  // Aborted multi/exec
 
 class ServerException extends PredisException {                     // Server-side errors
     public function toResponseError() {
@@ -908,10 +909,12 @@ class MultiExecBlock {
                 return;
             }
 
-            $execReply = (($reply = $this->_redisClient->exec()) instanceof \Iterator
-                ? iterator_to_array($reply)
-                : $reply
-            );
+            $reply = $this->_redisClient->exec();
+            if ($reply === null) {
+                throw new AbortedMultiExec('The current transaction has been aborted by the server');
+            }
+
+            $execReply = $reply instanceof \Iterator ? iterator_to_array($reply) : $reply;
             $commands  = &$this->_commands;
             $sizeofReplies = count($execReply);