瀏覽代碼

Fix a couple of corner cases for Predis\MultiExecContext.

Daniele Alessandri 14 年之前
父節點
當前提交
e4c45455fe
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      lib/Predis/MultiExecContext.php

+ 6 - 3
lib/Predis/MultiExecContext.php

@@ -105,9 +105,11 @@ class MultiExecContext {
     }
 
     public function discard() {
-        $this->_client->discard();
-        $this->reset();
-        $this->_discarded = true;
+        if ($this->_initialized) {
+            $this->_client->discard();
+            $this->reset();
+            $this->_discarded = true;
+        }
         return $this;
     }
 
@@ -128,6 +130,7 @@ class MultiExecContext {
                 );
             }
             if (count($this->_commands) > 0) {
+                $this->discard();
                 throw new ClientException(
                     'Cannot execute a transaction block after using fluent interface'
                 );