Skip to content

Commit 88a23a8

Browse files
committed
Setup: Sanity check for invalid table prefixes.
There are some table prefixes (for example, `7e1_`), which MySQL will try and parse as values when they're note quoted in backticks. Because not everything remembers to quote their table names, it's best if we just discourage their use during setup. Fixes #36422. git-svn-id: https://develop.svn.wordpress.org/trunk@37581 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 80c3e34 commit 88a23a8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/wp-admin/setup-config.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ function setup_config_display_header( $body_classes = array() ) {
278278
if ( ! empty( $wpdb->error ) )
279279
wp_die( $wpdb->error->get_error_message() . $tryagain_link );
280280

281+
$wpdb->query( "SELECT $prefix" );
282+
if ( ! $wpdb->last_error ) {
283+
// MySQL was able to parse the prefix as a value, which we don't want. Bail.
284+
wp_die( __( '<strong>ERROR</strong>: "Table Prefix" is invalid.' ) );
285+
}
286+
281287
// Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password().
282288
try {
283289
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';

0 commit comments

Comments
 (0)