[wp-trac] [WordPress Trac] #56836: PHP 8.1 Deprecation Warning for mysqli_real_connect

WordPress Trac noreply at wordpress.org
Sun Oct 16 23:25:25 UTC 2022


#56836: PHP 8.1 Deprecation Warning for mysqli_real_connect
------------------------------+-----------------------------
 Reporter:  nickchomey        |      Owner:  (none)
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Database          |    Version:  6.0.2
 Severity:  normal            |   Keywords:
  Focuses:  coding-standards  |
------------------------------+-----------------------------
 I'm getting these deprecation warnings in the debug.log

 {{{
 [16-Oct-2022 23:14:52 UTC] PHP Deprecated:  mysqli_real_connect(): Passing
 null to parameter #5 ($database) of type ?string is deprecated in
 /home/seeingtheforest.net/public_html/wp-includes/wp-db.php on line 1753
 [16-Oct-2022 23:14:52 UTC] PHP Deprecated:  mysqli_real_connect(): Passing
 null to parameter #6 ($port) of type ?int is deprecated in
 /home/seeingtheforest.net/public_html/wp-includes/wp-db.php on line 1753
 [16-Oct-2022 23:14:52 UTC] PHP Deprecated:  mysqli_real_connect(): Passing
 null to parameter #7 ($socket) of type ?string is deprecated in
 /home/seeingtheforest.net/public_html/wp-includes/wp-db.php on line 1753
 }}}

 I'm using PHP 8.1, so assume it is due to that. It probably happens in 8.0
 as well.

 If I trace the error with Xdebug, I can see that the problem is
 a) null is simply hardcoded for param 5
 b) port and socket are set to null if they aren't included in wp-
 config.php e.g. {{{define('DB_HOST', "localhost");}}}

 If I manually change param 5 to {{{""}}} and

 {{{
 $port    = "";
 $socket  = "";
 }}}

 in {{{wp-includes/wp-db.php -> parse_db_host()}}}

 then the problem goes away.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56836>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list