[wp-trac] [WordPress Trac] #42362: WordPress database error Unknown column 'wp_mywordpresssite' in 'field list'

WordPress Trac noreply at wordpress.org
Tue Aug 2 00:17:18 UTC 2022


#42362: WordPress database error Unknown column 'wp_mywordpresssite' in 'field
list'
------------------------------------------------+--------------------------
 Reporter:  lazam786                            |       Owner:
                                                |  SergeyBiryukov
     Type:  defect (bug)                        |      Status:  reviewing
 Priority:  normal                              |   Milestone:  6.1
Component:  Database                            |     Version:  4.6
 Severity:  normal                              |  Resolution:
 Keywords:  php8 php81 has-patch needs-testing  |     Focuses:
------------------------------------------------+--------------------------
Changes (by SergeyBiryukov):

 * milestone:  Future Release => 6.1


Comment:

 Replying to [comment:33 SergeyBiryukov]:
 > Just noting that the error appears to be more prominent with PHP 8.1, as
 reported in #54579:
 > > {{{
 > > [php:error] [pid 18811] [client 127.0.0.1:36932] PHP Fatal error:
 Uncaught mysqli_sql_exception: > > > Unknown column 'wp_' in 'field list'
 in /var/www/mylocalsite.com/wp-includes/wp-db.php:2056
 > > Stack trace:
 > > #0 /var/www/mylocalsite.com/wp-includes/wp-db.php(2056):
 mysqli_query()
 > > #1 /var/www/mylocalsite.com/wp-includes/wp-db.php(1945):
 wpdb->_do_query()
 > > #2 /var/www/mylocalsite.com/wp-admin/setup-config.php(317):
 wpdb->query()
 > > #3 {main}
 > >   thrown in /var/www/mylocalsite.com/wp-includes/wp-db.php on line
 2056, referer: http://mylocalsite.com/wp-admin/setup-config.php?step=1
 > > }}}

 To follow up on this, I believe the fatal error was resolved in [51582] /
 #52825, which prevents `mysqli_sql_exception` from being thrown.

 I was able to reproduce the initial issue:
 1. Remove `wp-config.php` if it exists.
 2. Open the home URL, which should then redirect to `wp-admin/setup-
 config.php`.
 3. Start the installation and proceed until `wp-config.php` is created.
 4. Check the error log for the `Unknown column 'wp_' in 'field list'`
 message.

 Replying to [comment:42 deksar]:
 > I have just tested the patch, it solved the problem, no more errors.

 Thank you! It resolves the issue in my testing too.

 I also tried the suggestion from comment:2:ticket:43167. It does not log
 an error for valid prefixes like `wp_`, but still does for invalid ones
 like `7e1_`:
 > `You have an error in your SQL syntax; check the manual that corresponds
 to your MariaDB server version for the right syntax to use near '7e1_' at
 line 1"`
 So changing the query does not seem to make a difference here, as it would
 still need some kind of error suppression.

 Moving to 6.1, as [attachment:"42362.2.diff"] appears to work as expected.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42362#comment:43>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list