First pass at Multisite support in DB repair. When MS, include main blog tables; when not MS, include non-MS global tables (users, usermeta). See #12083
git-svn-id: https://develop.svn.wordpress.org/trunk@13224 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3f2c21e53f
commit
1992489856
|
@ -31,35 +31,40 @@ if ( !defined('WP_ALLOW_REPAIR') ) {
|
||||||
|
|
||||||
$okay = true;
|
$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.
|
// Loop over the WP tables, checking and repairing as needed.
|
||||||
foreach ($wpdb->tables as $table) {
|
foreach ( $tables as $table ) {
|
||||||
if ( in_array( $table, $wpdb->old_tables ) )
|
if ( in_array( $table, $wpdb->old_tables ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table");
|
$check = $wpdb->get_row("CHECK TABLE {$prefix}$table");
|
||||||
if ( 'OK' == $check->Msg_text ) {
|
if ( 'OK' == $check->Msg_text ) {
|
||||||
echo "<p>The {$wpdb->prefix}$table table is okay.";
|
echo "<p>The {$prefix}$table table is okay.";
|
||||||
} else {
|
} else {
|
||||||
echo "<p>The {$wpdb->prefix}$table table is not okay. It is reporting the following error: <code>$check->Msg_text</code>. WordPress will attempt to repair this table…";
|
echo "<p>The {$prefix}$table table is not okay. It is reporting the following error: <code>$check->Msg_text</code>. WordPress will attempt to repair this table…";
|
||||||
$repair = $wpdb->get_row("REPAIR TABLE {$wpdb->prefix}$table");
|
$repair = $wpdb->get_row("REPAIR TABLE {$prefix}$table");
|
||||||
if ( 'OK' == $check->Msg_text ) {
|
if ( 'OK' == $check->Msg_text ) {
|
||||||
echo "<br /> Successfully repaired the {$wpdb->prefix}$table table.";
|
echo "<br /> Successfully repaired the {$prefix}$table table.";
|
||||||
} else {
|
} else {
|
||||||
echo "<br /> Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text<br />";
|
echo "<br /> Failed to repair the {prefix}$table table. Error: $check->Msg_text<br />";
|
||||||
$problems["{$wpdb->prefix}$table"] = $check->Msg_text;
|
$problems["{$prefix}$table"] = $check->Msg_text;
|
||||||
$okay = false;
|
$okay = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $okay && $optimize ) {
|
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 ) {
|
if ( 'Table is already up to date' == $check->Msg_text ) {
|
||||||
echo "<br /> The {$wpdb->prefix}$table table is already optimized.";
|
echo "<br /> The {$prefix}$table table is already optimized.";
|
||||||
} else {
|
} 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 )
|
if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text )
|
||||||
echo "<br /> Successfully optimized the {$wpdb->prefix}$table table.";
|
echo "<br /> Successfully optimized the {$prefix}$table table.";
|
||||||
else
|
else
|
||||||
echo "<br /> Failed to optimize the {$wpdb->prefix}$table table. Error: $check->Msg_text";
|
echo "<br /> Failed to optimize the {$prefix}$table table. Error: $check->Msg_text";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
|
|
Loading…
Reference in New Issue