Skip to content

Commit

Permalink
Minor fixes to load balancer for PHP 8.2+ warnings
Browse files Browse the repository at this point in the history
Fixes #951

Signed-off-by: Damien Regad <dregad@mantisbt.org>

Updated Changelog and added PR reference in commit message, back-ported
to hotfix/5.22 branch.
  • Loading branch information
Mike-Benoit authored and dregad committed Apr 15, 2023
1 parent f5f873c commit ef3d226
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions adodb-loadbalancer.inc.php
Expand Up @@ -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.
Expand All @@ -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 = [];


/**
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.md
Expand Up @@ -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
Expand Down

0 comments on commit ef3d226

Please sign in to comment.