From 9e97a77b196389c2db81e6294dc5a66407313215 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 22 Oct 2009 20:23:19 +0000 Subject: [PATCH] Add option to optimize tables git-svn-id: https://develop.svn.wordpress.org/trunk@12092 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/maint/repair.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/wp-admin/maint/repair.php b/wp-admin/maint/repair.php index c05b2b0d3b..7eb3abbf9a 100644 --- a/wp-admin/maint/repair.php +++ b/wp-admin/maint/repair.php @@ -24,6 +24,13 @@ if ( !defined('WP_ALLOW_REPAIR') ) { $problems = array(); check_admin_referer('repair_db'); + if ( 2 == $_GET['repair'] ) + $optimize = true; + else + $optimize = false; + + $okay = true; + // Loop over the WP tables, checking and repairing as needed. foreach ($wpdb->tables as $table) { if ( in_array($table, $wpdb->old_tables) ) @@ -31,17 +38,31 @@ if ( !defined('WP_ALLOW_REPAIR') ) { $check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table"); if ( 'OK' == $check->Msg_text ) { - echo "

The {$wpdb->prefix}$table table is okay.

"; + echo "

The {$wpdb->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…
"; + 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 {$wpb->prefix}$table"); if ( 'OK' == $check->Msg_text ) { - echo "    Sucessfully repaired the {$wpb->prefix}$table table.
"; + echo "
    Sucessfully repaired the {$wpb->prefix}$table table."; } else { - echo "    Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text
"; + echo "
    Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text
"; $problems["{$wpdb->prefix}$table"] = $check->Msg_text; + $okay = false; } } + if ( $okay && $optimize ) { + $check = $wpdb->get_row("ANALYZE TABLE {$wpdb->prefix}$table"); + if ( 'Table is already up to date' == $check->Msg_text ) { + echo "
    The {$wpb->prefix}$table table is already optimized."; + } else { + $check = $wpdb->get_row("OPTIMIZE TABLE {$wpdb->prefix}$table"); + if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) + echo "
    Sucessfully optimized the {$wpb->prefix}$table table."; + else + echo "
    Failed to optimize the {$wpdb->prefix}$table table. Error: $check->Msg_text"; + } + } + echo '

'; } if ( !empty($problems) ) { @@ -60,9 +81,10 @@ if ( !defined('WP_ALLOW_REPAIR') ) { _e('WordPress can automatically look for some common database problems and repair them. Repairing can take awhile, so please be patient.') ?>

+ +

\ No newline at end of file