Is it possible to run WordPress on PHP 8.1 right now? I have installed PHP 8.1 in XAMPP, but I can’t get WordPress to work. I get this error message:
[23-Nov-2021 18:44:43 UTC] PHP Fatal error: Uncaught
mysqli_sql_exception: Unknown column ‘wp_’ in ‘field list’ in
C:xampphtdocsmy_php_81_foldernormal_local_sitewp-includeswp-db.php:2056
Stack trace:
#0 C:xampphtdocsmy_php_81_foldernormal_local_sitewp-includeswp-db.php(2056):
mysqli_query(Object(mysqli), ‘SELECT wp_’)
#1 C:xampphtdocsmy_php_81_foldernormal_local_sitewp-includeswp-db.php(1945):
wpdb->do_query(‘SELECT wp‘)
#2 C:xampphtdocsmy_php_81_foldernormal_local_sitewp-adminsetup-config.php(317):
wpdb->query(‘SELECT wp_’)
#3 {main} thrown in C:xampphtdocsmy_php_81_foldernormal_local_sitewp-includeswp-db.php
on line 2056 [23-Nov-2021 18:45:45 UTC] PHP Fatal error: Uncaught
mysqli_sql_exception: Unknown column ‘wp_’ in ‘field list’ in
C:xampphtdocsmy_php_81_foldernormal_local_sitewp-includeswp-db.php:2056
I have verified that PHP 8.1 is being served to this folder and I can run PDO and mysqli commands that successfully create and modify local databases.
3
Answers
As of November 2021* WordPress is not yet fully compatible with PHP 8.1. The WordPress 5.9 release that is planned to be available on 25th January 2022 should be compatible with PHP 8.1.
For the time being, please use PHP 8.0 with WordPress to avoid weird bugs.
* PHP 8.1 was released on 25th November 2021
For anyone who reaches this in the next couple days before WordPress 5.9 comes out, I was able to get 5.8.3 working on PHP 8.1 by making a quick change to
wp-includes/wp-db.php
. I added this line afterif ( $this->use_mysqli )
in thedb_connect
method (line 1630):This change is one made in WordPress 5.9 itself, so should be fine.
@/SergeyBiryukov has pushed a bug fix which should be available in the next version of WordPress. If you’re having this challenge, you can suppress these errors by opening wp-admin/setup-config.php and replacing the following lines.
Replace
With
And Replace
With