Sfoglia il codice sorgente

Prevent warnings picking slave from empty pool.

Daniele Alessandri 9 anni fa
parent
commit
5d99914939
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      src/Connection/Aggregate/MasterSlaveReplication.php

+ 3 - 1
src/Connection/Aggregate/MasterSlaveReplication.php

@@ -207,7 +207,9 @@ class MasterSlaveReplication implements ReplicationInterface
      */
     protected function pickSlave()
     {
-        return $this->slaves[array_rand($this->slaves)];
+        if ($this->slaves) {
+            return $this->slaves[array_rand($this->slaves)];
+        }
     }
 
     /**