WordPress.org

Make WordPress Core

Changeset 13224


Ignore:
Timestamp:
02/19/2010 02:33:01 PM (8 years ago)
Author:
nacin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/maint/repair.php

    r12789 r13224  
    3232    $okay = true;
    3333
     34    $tables = array_merge( $wpdb->tables, is_multisite() ? $wpdb->global_tables : array( 'users', 'usermeta' ) );
     35    $prefix = $wpdb->prefix;
     36    if ( is_multisite() && ! defined('MULTISITE') ) // _1 to get MU-era main blog
     37        $prefix .= '_1';
     38
    3439    // Loop over the WP tables, checking and repairing as needed.
    35     foreach ($wpdb->tables as $table) {
    36         if ( in_array($table, $wpdb->old_tables) )
     40    foreach ( $tables as $table ) {
     41        if ( in_array( $table, $wpdb->old_tables ) )
    3742            continue;
    3843
    39         $check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table");
     44        $check = $wpdb->get_row("CHECK TABLE {$prefix}$table");
    4045        if ( 'OK' == $check->Msg_text ) {
    41             echo "<p>The {$wpdb->prefix}$table table is okay.";
     46            echo "<p>The {$prefix}$table table is okay.";
    4247        } else {
    43             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&hellip;";
    44             $repair = $wpdb->get_row("REPAIR TABLE {$wpdb->prefix}$table");
     48            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&hellip;";
     49            $repair = $wpdb->get_row("REPAIR TABLE {$prefix}$table");
    4550            if ( 'OK' == $check->Msg_text ) {
    46                 echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully repaired the {$wpdb->prefix}$table table.";
     51                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully repaired the {$prefix}$table table.";
    4752            } else {
    48                 echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text<br />";
    49                 $problems["{$wpdb->prefix}$table"] = $check->Msg_text;
     53                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the {prefix}$table table. Error: $check->Msg_text<br />";
     54                $problems["{$prefix}$table"] = $check->Msg_text;
    5055                $okay = false;
    5156            }
    5257        }
    5358        if ( $okay && $optimize ) {
    54             $check = $wpdb->get_row("ANALYZE TABLE {$wpdb->prefix}$table");
     59            $check = $wpdb->get_row("ANALYZE TABLE {$prefix}$table");
    5560            if ( 'Table is already up to date' == $check->Msg_text )  {
    56                 echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The {$wpdb->prefix}$table table is already optimized.";
     61                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The {$prefix}$table table is already optimized.";
    5762            } else {
    58                 $check = $wpdb->get_row("OPTIMIZE TABLE {$wpdb->prefix}$table");
     63                $check = $wpdb->get_row("OPTIMIZE TABLE {$prefix}$table");
    5964                if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text )
    60                     echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully optimized the {$wpdb->prefix}$table table.";
     65                    echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully optimized the {$prefix}$table table.";
    6166                else
    62                     echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the {$wpdb->prefix}$table table. Error: $check->Msg_text";
     67                    echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the {$prefix}$table table. Error: $check->Msg_text";
    6368            }
    6469        }
Note: See TracChangeset for help on using the changeset viewer.