WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/19/2010 07:57:03 PM (10 years ago)
Author:
nacin
Message:

Introduce wpdb::tables() to fetch table names on a global or blog scope. Remove very old and long deprecated $table{table} globals, fixes #11614. See #12083

File:
1 edited

Legend:

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

    r13224 r13229  
    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 
     34    $tables = $wpdb->tables( 'all', true );
    3935    // Loop over the WP tables, checking and repairing as needed.
    4036    foreach ( $tables as $table ) {
    41         if ( in_array( $table, $wpdb->old_tables ) )
    42             continue;
    43 
    44         $check = $wpdb->get_row("CHECK TABLE {$prefix}$table");
     37        $check = $wpdb->get_row("CHECK TABLE $table");
    4538        if ( 'OK' == $check->Msg_text ) {
    46             echo "<p>The {$prefix}$table table is okay.";
     39            echo "<p>The $table table is okay.";
    4740        } else {
    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");
     41            echo "<p>The $table table is not okay. It is reporting the following error: <code>$check->Msg_text</code>.  WordPress will attempt to repair this table&hellip;";
     42            $repair = $wpdb->get_row("REPAIR TABLE $table");
    5043            if ( 'OK' == $check->Msg_text ) {
    51                 echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully repaired the {$prefix}$table table.";
     44                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully repaired the $table table.";
    5245            } else {
    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;
     46                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the $table table. Error: $check->Msg_text<br />";
     47                $problems["$table"] = $check->Msg_text;
    5548                $okay = false;
    5649            }
    5750        }
    5851        if ( $okay && $optimize ) {
    59             $check = $wpdb->get_row("ANALYZE TABLE {$prefix}$table");
     52            $check = $wpdb->get_row("ANALYZE TABLE $table");
    6053            if ( 'Table is already up to date' == $check->Msg_text )  {
    61                 echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The {$prefix}$table table is already optimized.";
     54                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The $table table is already optimized.";
    6255            } else {
    63                 $check = $wpdb->get_row("OPTIMIZE TABLE {$prefix}$table");
     56                $check = $wpdb->get_row("OPTIMIZE TABLE $table");
    6457                if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text )
    65                     echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully optimized the {$prefix}$table table.";
     58                    echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully optimized the $table table.";
    6659                else
    67                     echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the {$prefix}$table table. Error: $check->Msg_text";
     60                    echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the $table table. Error: $check->Msg_text";
    6861            }
    6962        }
Note: See TracChangeset for help on using the changeset viewer.