aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/driver/mysqli.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-06-26 14:25:40 +0200
committerMarc Alexander <admin@m-a-styles.de>2014-06-26 14:33:08 +0200
commit40a65abc3ae312876842cc3e19220e74fa002667 (patch)
tree6d653cbc1960f68cbe268ae3d2fa3554a97ad66c /phpBB/phpbb/db/driver/mysqli.php
parent69b9aa2859441116c02ea0b36f6f3a53b8c1eda1 (diff)
downloadforums-40a65abc3ae312876842cc3e19220e74fa002667.tar
forums-40a65abc3ae312876842cc3e19220e74fa002667.tar.gz
forums-40a65abc3ae312876842cc3e19220e74fa002667.tar.bz2
forums-40a65abc3ae312876842cc3e19220e74fa002667.tar.xz
forums-40a65abc3ae312876842cc3e19220e74fa002667.zip
[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
Diffstat (limited to 'phpBB/phpbb/db/driver/mysqli.php')
-rw-r--r--phpBB/phpbb/db/driver/mysqli.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php
index 8fc306b2cc..2ed08211ad 100644
--- a/phpBB/phpbb/db/driver/mysqli.php
+++ b/phpBB/phpbb/db/driver/mysqli.php
@@ -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 != '')
{