WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 22 months ago

Last modified 15 months ago

#40655 closed defect (bug) (fixed)

DB error during installation

Reported by: FlyerUA Owned by: pento
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.6
Component: Database Keywords:
Focuses: Cc:

Description

$wpdb->query( "SELECT $prefix" ); at line 279 of setup-config.php throws a DB error and that's not exactly nice thing to have during installation. If you insist on having a check like this, perhaps suppress the error from this call?

Change History (9)

#1 follow-up: @SergeyBiryukov
2 years ago

  • Component changed from General to Database
  • Milestone changed from Awaiting Review to 4.9
  • Version changed from 4.7.4 to 4.6

Found a few other reports:

At least two of them mention that the issue happens when installing WordPress on IIS.

The error message is:

Unknown column 'wp_' in 'field list' for query SELECT wp_

Introduced in [37581]. cc @pento

Last edited 15 months ago by SergeyBiryukov (previous) (diff)

#2 @FlyerUA
2 years ago

Not unique to IIS as I'm not using that.

#3 in reply to: ↑ 1 ; follow-up: @danieltj
23 months ago

Replying to SergeyBiryukov:

Found a few other reports:
https://wordpress.org/support/topic/unknown-column-wp_-error-when-installing-wordpress-46/
https://wordpress.org/support/topic/installing-wordpress-46/
https://wordpress.org/support/topic/problem-installing-4-7-on-iis-7-with-php-7/

At least two of them mention that the issue happens when installing WordPress on IIS.

The error message is:

Unknown column 'wp_' in 'field list' for query SELECT wp_

Introduced in [37581]. cc @pento

I'd suggest that we just make it more user friendly like the other error messages. I think what it's doing is fine because it'll error anyway when using an invalid prefix so the idea is we have the user change it at some point to something valid. I've slightly changed the wording and added the return link to easily go back.

So what about this?

setup-config.php (line 279)

  $wpdb->query( "SELECT $prefix" );
  if ( ! $wpdb->last_error ) {
      // MySQL was able to parse the prefix as a value, which we don't want. Bail.
      wp_die( __( '<strong>ERROR</strong>: "Table Prefix" is invalid, please choose a different prefix.' . $tryagain_link ) );
  }

...which replaces this

  $wpdb->query( "SELECT $prefix" );
  if ( ! $wpdb->last_error ) {
      // MySQL was able to parse the prefix as a value, which we don't want. Bail.
      wp_die( __( '<strong>ERROR</strong>: "Table Prefix" is invalid.' ) );
  }

#4 in reply to: ↑ 3 ; follow-up: @SergeyBiryukov
23 months ago

Replying to danieltj:

I'd suggest that we just make it more user friendly like the other error messages. I think what it's doing is fine because it'll error anyway when using an invalid prefix so the idea is we have the user change it at some point to something valid.

I don't mind making the "Table Prefix" is invalid message more friendly, but that's not the issue here, wp_ is a perfectly valid prefix.

The check added in [37581] is supposed to disallow prefixes like 7e1_ that could be parsed as a value. This appears to work as expected, but in some cases it triggers the Unknown column 'wp_' in 'field list' for query SELECT wp_ error, which should be silently discarded, not displayed to the user.

Last edited 23 months ago by SergeyBiryukov (previous) (diff)

#5 in reply to: ↑ 4 @danieltj
23 months ago

Replying to SergeyBiryukov:

Replying to danieltj:

I'd suggest that we just make it more user friendly like the other error messages. I think what it's doing is fine because it'll error anyway when using an invalid prefix so the idea is we have the user change it at some point to something valid.

I don't mind making the "Table Prefix" is invalid message more friendly, but that's not the issue here, wp_ is a perfectly valid prefix.

The check added in [37581] is supposed to disallow prefixes like 7e1_ that could be parsed as a value. This appears to work as expected, but in some cases it triggers the Unknown column 'wp_' in 'field list' for query SELECT wp_ error, which should be silently discarded, not displayed to the user.

Ahh I see. I'll have to revisit this then because I couldn't replicate the wp_ prefix error, only with the 7e1_ prefix.

#6 @pento
22 months ago

  • Owner set to pento
  • Resolution set to fixed
  • Status changed from new to closed

In 41631:

Setup: Hide database errors while testing the table prefix.

If DB errors are shown during installation, the table prefix test will also show an error, even though we're deliberately trying to generate that error.

Fixes #40655.

#7 @SergeyBiryukov
21 months ago

#42362 was marked as a duplicate.

#8 @lazam786
21 months ago

AS I am stuck with my installation due to this error "Unknown column 'wp_' in 'field list'", is there any alternate way to install wordpress. Is this is the problem due to my mysql version (5.7 ) or word press (4.8.2). Will this be resolved if I use older versions.

Please help as I am stuck with my project.

This ticket was mentioned in Slack in #core by sergey. View the logs.


15 months ago

Note: See TracTickets for help on using tickets.