diff --git a/wp-admin/maint/repair.php b/wp-admin/maint/repair.php index d8934caf46..3a8d7b0eec 100644 --- a/wp-admin/maint/repair.php +++ b/wp-admin/maint/repair.php @@ -31,35 +31,40 @@ if ( !defined('WP_ALLOW_REPAIR') ) { $okay = true; + $tables = array_merge( $wpdb->tables, is_multisite() ? $wpdb->global_tables : array( 'users', 'usermeta' ) ); + $prefix = $wpdb->prefix; + if ( is_multisite() && ! defined('MULTISITE') ) // _1 to get MU-era main blog + $prefix .= '_1'; + // Loop over the WP tables, checking and repairing as needed. - foreach ($wpdb->tables as $table) { - if ( in_array($table, $wpdb->old_tables) ) + foreach ( $tables as $table ) { + if ( in_array( $table, $wpdb->old_tables ) ) continue; - $check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table"); + $check = $wpdb->get_row("CHECK TABLE {$prefix}$table"); if ( 'OK' == $check->Msg_text ) { - echo "
The {$wpdb->prefix}$table table is okay."; + echo "
The {$prefix}$table table is okay."; } else { - echo "
The {$wpdb->prefix}$table table is not okay. It is reporting the following error: $check->Msg_text
. WordPress will attempt to repair this table…";
- $repair = $wpdb->get_row("REPAIR TABLE {$wpdb->prefix}$table");
+ echo "
The {$prefix}$table table is not okay. It is reporting the following error: $check->Msg_text
. WordPress will attempt to repair this table…";
+ $repair = $wpdb->get_row("REPAIR TABLE {$prefix}$table");
if ( 'OK' == $check->Msg_text ) {
- echo "
Successfully repaired the {$wpdb->prefix}$table table.";
+ echo "
Successfully repaired the {$prefix}$table table.";
} else {
- echo "
Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text
";
- $problems["{$wpdb->prefix}$table"] = $check->Msg_text;
+ echo "
Failed to repair the {prefix}$table table. Error: $check->Msg_text
";
+ $problems["{$prefix}$table"] = $check->Msg_text;
$okay = false;
}
}
if ( $okay && $optimize ) {
- $check = $wpdb->get_row("ANALYZE TABLE {$wpdb->prefix}$table");
+ $check = $wpdb->get_row("ANALYZE TABLE {$prefix}$table");
if ( 'Table is already up to date' == $check->Msg_text ) {
- echo "
The {$wpdb->prefix}$table table is already optimized.";
+ echo "
The {$prefix}$table table is already optimized.";
} else {
- $check = $wpdb->get_row("OPTIMIZE TABLE {$wpdb->prefix}$table");
+ $check = $wpdb->get_row("OPTIMIZE TABLE {$prefix}$table");
if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text )
- echo "
Successfully optimized the {$wpdb->prefix}$table table.";
+ echo "
Successfully optimized the {$prefix}$table table.";
else
- echo "
Failed to optimize the {$wpdb->prefix}$table table. Error: $check->Msg_text";
+ echo "
Failed to optimize the {$prefix}$table table. Error: $check->Msg_text";
}
}
echo '