Skip to content

Commit aa8d926

Browse files
author
Till Brehm
committed
Merge branch 'stable-3.1' of git.ispconfig.org:ispconfig/ispconfig3 into stable-3.1
2 parents f5bb355 + b9b97e2 commit aa8d926

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

interface/lib/classes/db_mysql.inc.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,15 @@ public function __construct($prefix = '') {
7474
$this->dbCharset = $conf[$prefix.'db_charset'];
7575
$this->dbNewLink = $conf[$prefix.'db_new_link'];
7676
$this->dbClientFlags = $conf[$prefix.'db_client_flags'];
77-
7877
$this->_iConnId = mysqli_init();
79-
$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
80-
$try = 0;
81-
while($this->_iConnId->connect_error && $try < 5) {
82-
if($try > 0) sleep(1);
8378

84-
$try++;
85-
$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
79+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
80+
for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
81+
sleep($try);
82+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
8683
}
8784

88-
if($this->_iConnId->connect_error) {
85+
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
8986
$this->_iConnId = null;
9087
$this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!');
9188
return false;
@@ -244,7 +241,7 @@ private function _query($sQuery = '') {
244241
$try++;
245242
$ok = mysqli_ping($this->_iConnId);
246243
if(!$ok) {
247-
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
244+
if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
248245
if($try > 4) {
249246
$this->_sqlerror('DB::query -> reconnect');
250247
return false;

server/lib/app.inc.php

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function __construct() {
5151
*/
5252

5353
if($conf['dbmaster_host'] != '' && ($conf['dbmaster_host'] != $conf['db_host'] || ($conf['dbmaster_host'] == $conf['db_host'] && $conf['dbmaster_database'] != $conf['db_database']))) {
54-
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port']);
54+
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port'], $conf['dbmaster_client_flags']);
5555
} else {
5656
$this->dbmaster = $this->db;
5757
}

server/lib/classes/db_mysql.inc.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class db
6464
*/
6565

6666
// constructor
67-
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL) {
67+
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL, $flags = NULL) {
6868
global $app, $conf;
6969

7070
$this->dbHost = $host ? $host : $conf['db_host'];
@@ -74,19 +74,16 @@ public function __construct($host = NULL , $user = NULL, $pass = NULL, $database
7474
$this->dbPass = $pass ? $pass : $conf['db_password'];
7575
$this->dbCharset = $conf['db_charset'];
7676
$this->dbNewLink = $conf['db_new_link'];
77-
$this->dbClientFlags = $conf['db_client_flags'];
78-
77+
$this->dbClientFlags = $flags ? $flags : $conf['db_client_flags'];
7978
$this->_iConnId = mysqli_init();
80-
$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
81-
$try = 0;
82-
while($this->_iConnId->connect_error && $try < 5) {
83-
if($try > 0) sleep(1);
8479

85-
$try++;
86-
$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
80+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
81+
for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
82+
sleep($try);
83+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
8784
}
8885

89-
if($this->_iConnId->connect_error) {
86+
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
9087
$this->_iConnId = null;
9188
$this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!', '', true);
9289
return false;
@@ -198,7 +195,7 @@ private function _query($sQuery = '') {
198195
$try++;
199196
$ok = mysqli_ping($this->_iConnId);
200197
if(!$ok) {
201-
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
198+
if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
202199
if($this->errorNumber == '111') {
203200
// server is not available
204201
if($try > 9) {

0 commit comments

Comments
 (0)