From ef3d226de1a5008bef53218ee9aeaaff85fcf7a6 Mon Sep 17 00:00:00 2001 From: Mike-Benoit Date: Wed, 12 Apr 2023 08:58:57 -0700 Subject: [PATCH] Minor fixes to load balancer for PHP 8.2+ warnings Fixes #951 Signed-off-by: Damien Regad Updated Changelog and added PR reference in commit message, back-ported to hotfix/5.22 branch. --- adodb-loadbalancer.inc.php | 12 ++++++------ docs/changelog.md | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/adodb-loadbalancer.inc.php b/adodb-loadbalancer.inc.php index 88f5d0fdc..de067805b 100644 --- a/adodb-loadbalancer.inc.php +++ b/adodb-loadbalancer.inc.php @@ -38,17 +38,17 @@ class ADOdbLoadBalancer /** * @var bool|array All connections to each database. */ - protected $connections = false; + protected $connections = []; /** * @var bool|array Just connections to the write capable database. */ - protected $connections_write = false; + protected $connections_write = []; /** * @var bool|array Just connections to the readonly database. */ - protected $connections_readonly = false; + protected $connections_readonly = []; /** * @var array Counts of all connections and their types. @@ -73,12 +73,12 @@ class ADOdbLoadBalancer /** * @var bool Session variables that must be maintained across all connections, ie: SET TIME ZONE. */ - protected $session_variables = false; + protected $session_variables = []; /** * @var bool Called immediately after connecting to any DB. */ - protected $user_defined_session_init_sql = false; + protected $user_defined_session_init_sql = []; /** @@ -403,7 +403,7 @@ public function setSessionVariable($name, $value, $execute_immediately = true) */ private function executeSessionVariables($adodb_obj = false) { - if (is_array($this->session_variables)) { + if (is_array($this->session_variables) && count($this->session_variables) > 0) { $sql = ''; foreach ($this->session_variables as $name => $value) { // $sql .= 'SET SESSION '. $name .' '. $value; diff --git a/docs/changelog.md b/docs/changelog.md index 8bffeeef0..d87d5c5a0 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -20,6 +20,8 @@ Older changelogs: - Creation of dynamic property deprecated warning in PHP 8.2 [#954](https://github.com/ADOdb/ADOdb/issues/954) +- loadbalancer: PHP 8.2 warnings + [#951](https://github.com/ADOdb/ADOdb/issues/951) ## [5.22.5] - 2023-04-03