Skip to content

Commit d04259b

Browse files
committed
Fix mysqli errors in PHP 8.1
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 3447d30 commit d04259b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

includes/db/mysqli.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ class dbal_mysqli_qi extends \phpbb\db\driver\mysqli
2626
*/
2727
public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false)
2828
{
29+
/*
30+
* As of PHP 8.1 MySQLi default error mode is set to MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT
31+
* See https://wiki.php.net/rfc/mysqli_default_errmode
32+
* Since phpBB implements own SQL errors handling, explicitly set it back to MYSQLI_REPORT_OFF
33+
*/
34+
if (PHP_VERSION_ID >= 80100)
35+
{
36+
@mysqli_report(MYSQLI_REPORT_OFF);
37+
}
38+
2939
$this->persistency = $persistency;
3040
$this->user = $sqluser;
3141
$this->server = $sqlserver;
@@ -34,7 +44,7 @@ public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port
3444

3545
$this->sql_layer = 'mysql_41';
3646

37-
// Persistant connections not supported by the mysqli extension?
47+
// Persistent connections not supported by the mysqli extension?
3848
$this->db_connect_id = @mysqli_connect($this->server, $this->user, $sqlpassword, null, $port);
3949

4050
if ($this->db_connect_id)

0 commit comments

Comments
 (0)