WordPress.org

Make WordPress Core

Changeset 12092


Ignore:
Timestamp:
10/22/09 20:23:19 (5 years ago)
Author:
ryan
Message:

Add option to optimize tables

File:
1 edited

Legend:

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

    r11902 r12092  
    2525    check_admin_referer('repair_db'); 
    2626 
     27    if ( 2 == $_GET['repair'] ) 
     28        $optimize = true; 
     29    else 
     30        $optimize = false; 
     31 
     32    $okay = true; 
     33 
    2734    // Loop over the WP tables, checking and repairing as needed. 
    2835    foreach ($wpdb->tables as $table) { 
     
    3239        $check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table"); 
    3340        if ( 'OK' == $check->Msg_text ) { 
    34             echo "<p>The {$wpdb->prefix}$table table is okay.</p>"; 
     41            echo "<p>The {$wpdb->prefix}$table table is okay."; 
    3542        } else { 
    36             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;<br/>"; 
     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;"; 
    3744            $repair = $wpdb->get_row("REPAIR TABLE {$wpb->prefix}$table"); 
    3845            if ( 'OK' == $check->Msg_text ) { 
    39                 echo "&nbsp;&nbsp;&nbsp;&nbsp;Sucessfully repaired the {$wpb->prefix}$table table.<br />"; 
     46                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Sucessfully repaired the {$wpb->prefix}$table table."; 
    4047            } else { 
    41                 echo "&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text<br />"; 
     48                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text<br />"; 
    4249                $problems["{$wpdb->prefix}$table"] = $check->Msg_text; 
     50                $okay = false; 
    4351            } 
    4452        } 
     53        if ( $okay && $optimize ) { 
     54            $check = $wpdb->get_row("ANALYZE TABLE {$wpdb->prefix}$table"); 
     55            if ( 'Table is already up to date' == $check->Msg_text )  { 
     56                echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The {$wpb->prefix}$table table is already optimized."; 
     57            } else { 
     58                $check = $wpdb->get_row("OPTIMIZE TABLE {$wpdb->prefix}$table"); 
     59                if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) 
     60                    echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Sucessfully optimized the {$wpb->prefix}$table table."; 
     61                else 
     62                    echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the {$wpdb->prefix}$table table. Error: $check->Msg_text"; 
     63            } 
     64        } 
     65        echo '</p>'; 
    4566    } 
    4667 
     
    6182?> 
    6283    <p class="step"><a class="button" href="<?php echo wp_nonce_url('repair.php?repair=1', 'repair_db') ?>"><?php _e( 'Repair Database' ); ?></a></p> 
     84    <?php _e('WordPress can also attempt to optimize the database.  This improves performance in some situations.  Repairing and optimizing the database can take a long time and the database will be locked while optimizing.'); ?> 
     85    <p class="step"><a class="button" href="<?php echo wp_nonce_url('repair.php?repair=2', 'repair_db') ?>"><?php _e( 'Repair and Optimize Database' ); ?></a></p> 
    6386<?php 
    6487} 
    65  
    6688?> 
    6789</body> 
Note: See TracChangeset for help on using the changeset viewer.