mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Database: Suppress errors when checking the validity of table prefix during installation.
There are some table prefixes (for example, `7e1_`), which the database will try and parse as values unless they are quoted in backticks. Because not everyone remembers to quote their table names, WordPress discourages use of such prefixes during setup. To test if the table prefix is valid, WordPress executes a query deliberately trying to generate an error: > `Unknown column 'wp_' in 'field list'` which means the prefix is safe to use, as the database was not able to parse it as a value. Previously, this error would not be displayed to the user in a typical configuration, but would be logged on the server via `wpdb::print_error()`, and in some cases could block the installation. This commit makes sure the error is still checked to display a proper message in case the prefix needs to be edited, but otherwise is silently discarded instead of being logged. Follow-up to [37581], [41631], [51582]. Props pento, lazam786, Velochicdunord, irecinius, mikemanzo, dd32, blackawxs, codewhy, psykro, burgiuk, mdrago, maythamalsudany, peterwilsoncc, sumitsingh, deksar, SergeyBiryukov. Fixes #42362. git-svn-id: https://develop.svn.wordpress.org/trunk@53812 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fd1e1f17eb
commit
86fd171713
@ -311,9 +311,10 @@ switch ( $step ) {
|
||||
wp_die( $wpdb->error->get_error_message() . $tryagain_link );
|
||||
}
|
||||
|
||||
$errors = $wpdb->hide_errors();
|
||||
$errors = $wpdb->suppress_errors();
|
||||
$wpdb->query( "SELECT $prefix" );
|
||||
$wpdb->show_errors( $errors );
|
||||
$wpdb->suppress_errors( $errors );
|
||||
|
||||
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.' ) );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user