Quellcode durchsuchen

Make sure that Predis\MultiExecBlock and Predis\PubSubContext are not initialized over a cluster of connections.

Daniele Alessandri vor 14 Jahren
Ursprung
Commit
3853e62d34
1 geänderte Dateien mit 10 neuen und 0 gelöschten Zeilen
  1. 10 0
      lib/Predis.php

+ 10 - 0
lib/Predis.php

@@ -828,6 +828,11 @@ class MultiExecBlock {
     }
 
     private function checkCapabilities(Client $redisClient) {
+        if (Shared\Utils::isCluster($redisClient->getConnection())) {
+            throw new \Predis\ClientException(
+                'Cannot initialize a MULTI/EXEC context over a cluster of connections'
+            );
+        }
         $profile = $redisClient->getProfile();
         if ($profile->supportsCommands(array('multi', 'exec', 'discard')) === false) {
             throw new \Predis\ClientException(
@@ -1008,6 +1013,11 @@ class PubSubContext implements \Iterator {
     }
 
     private function checkCapabilities(Client $redisClient) {
+        if (Shared\Utils::isCluster($redisClient->getConnection())) {
+            throw new \Predis\ClientException(
+                'Cannot initialize a PUB/SUB context over a cluster of connections'
+            );
+        }
         $profile = $redisClient->getProfile();
         $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe');
         if ($profile->supportsCommands($commands) === false) {