From fc87fad390ff6307054a179d56a928ee08b8eec2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20G=C3=B3mez?= <sergio@uco.es>
Date: Thu, 29 Mar 2018 11:55:38 +0200
Subject: [PATCH] Fix count slave checking

The use of count function is wrong and unnecessary. If the array is
empty the foreach loop will not run.
---
 lib/SimpleSAML/Database.php | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/lib/SimpleSAML/Database.php b/lib/SimpleSAML/Database.php
index 85e19134e..8a189386d 100644
--- a/lib/SimpleSAML/Database.php
+++ b/lib/SimpleSAML/Database.php
@@ -90,18 +90,16 @@ class Database
 
         // connect to any configured slaves
         $slaves = $config->getArray('database.slaves', array());
-        if (count($slaves >= 1)) {
-            foreach ($slaves as $slave) {
-                array_push(
-                    $this->dbSlaves,
-                    $this->connect(
-                        $slave['dsn'],
-                        $slave['username'],
-                        $slave['password'],
-                        $driverOptions
-                    )
-                );
-            }
+        foreach ($slaves as $slave) {
+            array_push(
+                $this->dbSlaves,
+                $this->connect(
+                    $slave['dsn'],
+                    $slave['username'],
+                    $slave['password'],
+                    $driverOptions
+                )
+            );
         }
 
         $this->tablePrefix = $config->getString('database.prefix', '');
-- 
GitLab