mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-17 15:11:40 +02:00
Merge pull request #6763 from rxu/ticket/17455
[ticket/17455] Fix PHP warning on MySQLi connection failure
This commit is contained in:
@@ -59,14 +59,17 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db_connect_id = mysqli_init();
|
if (!$this->db_connect_id = mysqli_init())
|
||||||
|
|
||||||
if (!@mysqli_real_connect($this->db_connect_id, $this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket, MYSQLI_CLIENT_FOUND_ROWS))
|
|
||||||
{
|
{
|
||||||
$this->db_connect_id = '';
|
$this->connect_error = 'Failed to initialize MySQLi object.';
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (!@mysqli_real_connect($this->db_connect_id, $this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket, MYSQLI_CLIENT_FOUND_ROWS))
|
||||||
|
{
|
||||||
|
$this->connect_error = 'Failed to establish a connection to the MySQL database engine. Please ensure MySQL server is running and the database configuration parameters are correct.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db_connect_id && $this->dbname != '')
|
if (!$this->connect_error && $this->db_connect_id && $this->dbname != '')
|
||||||
{
|
{
|
||||||
// Disable loading local files on client side
|
// Disable loading local files on client side
|
||||||
@mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, false);
|
@mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, false);
|
||||||
@@ -357,15 +360,8 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||||||
if ($this->db_connect_id)
|
if ($this->db_connect_id)
|
||||||
{
|
{
|
||||||
$error = [
|
$error = [
|
||||||
'message' => $this->db_connect_id->error,
|
'message' => $this->db_connect_id->connect_error ?: $this->db_connect_id->error,
|
||||||
'code' => $this->db_connect_id->errno,
|
'code' => $this->db_connect_id->connect_errno ?: $this->db_connect_id->errno,
|
||||||
];
|
|
||||||
}
|
|
||||||
else if (function_exists('mysqli_connect_error'))
|
|
||||||
{
|
|
||||||
$error = [
|
|
||||||
'message' => $this->db_connect_id->connect_error,
|
|
||||||
'code' => $this->db_connect_id->connect_errno,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user