[wp-trac] [WordPress Trac] #57765: mysqli_query call in wp-includes/wp-db.php generates fatal error during first run of WP with PHP 8.1

WordPress Trac noreply at wordpress.org
Sat Feb 18 15:57:52 UTC 2023


#57765: mysqli_query call in wp-includes/wp-db.php generates fatal error during
first run of WP with PHP 8.1
--------------------------+-----------------------------
 Reporter:  lovingboth    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:  6.1.1
 Severity:  major         |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 Server: new upgrade of Ubuntu 20.04 to Ubuntu 22.04. As part of this, PHP
 8.1 replaced PHP 7.4

 Download latest.tar.gz, unzip, create empty database, plus setup access
 passwords etc.

 On first run, rather than see the 'which language' start of the install
 process, there's a white screen. Apache 2.4 error log says

 {{{
 Got error 'PHP message: PHP Fatal error: Uncaught mysqli_sql_exception:
 Table '[site-specific]wp_options' doesn't exist in
 /home/user/public_html/[site]/wp-includes/wp-db.php:2056
 }}}

 It turns out that with PHP 8.1, this is what mysqli_query does by default
 when it can't find a table.

 (See, for example https://php.watch/versions/8.1/mysqli-error-mode)

 Adding

 {{{
 mysqli_report(MYSQLI_REPORT_OFF); /* fixes install */
 }}}

 immediately before line 1056 stops it from doing so, and the install
 proceeds as normal. What that does on earlier versions that are out of
 support as far as the PHP devs are concerned, like 7.4, I don't know.

 It is possible that not doing any wp-config.php setup prior to the first
 run would mean that WP notices that there's no database access somewhere
 else and avoids this, but that's not many people's workflow. I would be
 shocked if some control panels' automated installations did not set up wp-
 config.php prior to the first run, for example.

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


More information about the wp-trac mailing list