소스 검색

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'
                 );