Skip to content

Commit f290aee

Browse files
committed
Small bugfix to not validate the Slave when it's not enabled
1 parent 4233563 commit f290aee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/classes/mysqlims.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class mysqlims extends mysqli
66
{
77
private $mysqliW;
88
private $mysqliR = null;
9+
private $slave = false;
910

1011
/*
1112
* Pass main and slave connection arrays to the constructor, and strict as true/false
@@ -27,6 +28,7 @@ public function __construct($main, $slave = false, $strict = false)
2728
$this->mysqliR = new mysqli_strict($slave['host'],
2829
$slave['user'], $slave['pass'],
2930
$slave['name'], $slave['port']);
31+
$this->slave = true;
3032
}
3133
} else {
3234
$this->mysqliW = new mysqli($main['host'],
@@ -37,14 +39,15 @@ public function __construct($main, $slave = false, $strict = false)
3739
$this->mysqliR = new mysqli($slave['host'],
3840
$slave['user'], $slave['pass'],
3941
$slave['name'], $slave['port']);
42+
$this->slave = true;
4043
}
4144
}
4245

4346
if ($this->mysqliW->connect_errno) {
4447
throw new Exception("Failed to connect to MySQL: (".$this->mysqliW->connect_errno.") ".$this->mysqliW->connect_error);
4548
}
4649

47-
if ($this->mysqliR->connect_errno) {
50+
if ($this->mysqliR->connect_errno && $this->slave === true) {
4851
throw new Exception("Failed to connect to MySQL: (".$this->mysqliR->connect_errno.") ".$this->mysqliR->connect_error);
4952
}
5053
}

0 commit comments

Comments
 (0)