Automattic / HyperDB

HyperDB is an advanced database class that supports replication, failover, load balancing, and partitioning.
105 stars 22 forks source link

Undefined variable: host #40

Open cfinke opened 2 years ago

cfinke commented 2 years ago

In db_connect(), if the condition while ( ( $group_key = array_shift( $this->unused_servers[ $dbhname ] ) ) ) { is never met, $host and $port will be undefined when the $error_details array is created, generating a PHP notice.

It could be fixed by just adding:

if ( ! isset( $host ) ) { $host = ''; }
if ( ! isset( $port ) ) { $port = ''; }

before $error_details, but I don't know if that would be masking the root issue (should the while loop always execute at least once?) or not.