Browse Source

Fix internal flags for MULTI / EXEC and PUB/SUB contexts.

Do not ask me why I was using 0x (the prefix for hexadecimal notation)
when what we really need here is 0b (the prefix for binary notation).
Really, everything was working by sheer coincidence.

Since 0b has been added in PHP 5.4, we rely on plain decimal numbers
to define our constants for now.
Daniele Alessandri 12 years ago
parent
commit
6e9db69e72
3 changed files with 18 additions and 10 deletions
  1. 8 0
      CHANGELOG.md
  2. 4 4
      lib/Predis/PubSub/PubSubContext.php
  3. 6 6
      lib/Predis/Transaction/MultiExecContext.php

+ 8 - 0
CHANGELOG.md

@@ -1,3 +1,11 @@
+v0.7.4 (2012-xx-xx)
+===============================================================================
+
+- __FIX__: the internal flags used to track the state of PUB/SUB and MULTI/EXEC
+  contexts were defined using a wrong notation (hexadecimal instead of binary).
+  Fortunately everything was working as expected, even if by sheer coincidence.
+
+
 v0.7.3 (2012-06-01)
 ===============================================================================
 

+ 4 - 4
lib/Predis/PubSub/PubSubContext.php

@@ -30,9 +30,9 @@ class PubSubContext implements \Iterator
     const MESSAGE      = 'message';
     const PMESSAGE     = 'pmessage';
 
-    const STATUS_VALID       = 0x0001;
-    const STATUS_SUBSCRIBED  = 0x0010;
-    const STATUS_PSUBSCRIBED = 0x0100;
+    const STATUS_VALID       = 1;   // 0b0001
+    const STATUS_SUBSCRIBED  = 2;   // 0b0010
+    const STATUS_PSUBSCRIBED = 4;   // 0b0100
 
     private $client;
     private $position;
@@ -245,7 +245,7 @@ class PubSubContext implements \Iterator
      */
     private function invalidate()
     {
-        $this->statusFlags = 0x0000;
+        $this->statusFlags = 0; // 0b0000;
     }
 
     /**

+ 6 - 6
lib/Predis/Transaction/MultiExecContext.php

@@ -28,12 +28,12 @@ use Predis\Protocol\ProtocolException;
  */
 class MultiExecContext
 {
-    const STATE_RESET       = 0x00000;
-    const STATE_INITIALIZED = 0x00001;
-    const STATE_INSIDEBLOCK = 0x00010;
-    const STATE_DISCARDED   = 0x00100;
-    const STATE_CAS         = 0x01000;
-    const STATE_WATCH       = 0x10000;
+    const STATE_RESET       = 0;    // 0b00000
+    const STATE_INITIALIZED = 1;    // 0b00001
+    const STATE_INSIDEBLOCK = 2;    // 0b00010
+    const STATE_DISCARDED   = 4;    // 0b00100
+    const STATE_CAS         = 8;    // 0b01000
+    const STATE_WATCH       = 16;   // 0b10000
 
     private $state;
     private $canWatch;