1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-29 02:29:21 +02:00

[ticket/12764] Properly handle errors upon connecting to MySQLi database

As the db_connect_id gets set up by mysql_init(), the db_connect_id will be an
object with empty settings instead of just empty. Even if mysql_real_connect()
encounters an error upon connecting, the db_connect_id is still set. This
will result in trying to just access the database which obviously does
nothing.
By setting db_connect_id to an empty string, the script will not try to query
th database and properly handle any errors that occur upon connecting.

PHPBB3-12764
This commit is contained in:
Marc Alexander 2014-06-26 14:25:40 +02:00
parent 69b9aa2859
commit 40a65abc3a

View File

@ -61,7 +61,11 @@ class mysqli extends \phpbb\db\driver\mysql_base
}
$this->db_connect_id = mysqli_init();
@mysqli_real_connect($this->db_connect_id, $this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket, MYSQLI_CLIENT_FOUND_ROWS);
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 = '';
}
if ($this->db_connect_id && $this->dbname != '')
{