Browse Source

Fix ISSUE #27.

Daniele Alessandri 14 năm trước cách đây
mục cha
commit
e5f010deb8
2 tập tin đã thay đổi với 5 bổ sung4 xóa
  1. 1 1
      CHANGELOG
  2. 4 3
      lib/Predis.php

+ 1 - 1
CHANGELOG

@@ -27,7 +27,7 @@ v0.6.6 (2011-xx-xx)
   * SUBSCRIBE and PSUBSCRIBE can accept a list of channels for subscription.
 
   * FIX: some client-side clean-ups for MULTI/EXEC were handled incorrectly in 
-    a couple of corner cases.
+    a couple of corner cases. See also ISSUE #27.
 
 v0.6.5 (2011-02-12)
   * FIX: due to an untested internal change introduced in v0.6.4, a wrong 

+ 4 - 3
lib/Predis.php

@@ -1062,8 +1062,9 @@ class MultiExecBlock {
     }
 
     public function discard() {
-        if ($this->_initialized === true || $this->_checkAndSet) {
-            $this->_redisClient->discard();
+        if ($this->_initialized === true) {
+            $command = $this->_checkAndSet ? 'unwatch' : 'discard';
+            $this->_redisClient->$command();
             $this->reset();
             $this->_discarded = true;
         }
@@ -1132,7 +1133,7 @@ class MultiExecBlock {
 
             if (count($this->_commands) === 0) {
                 if ($this->_watchedKeys) {
-                    $this->_redisClient->discard();
+                    $this->discard();
                     return;
                 }
                 return;