Index: repair.php
===================================================================
--- repair.php	(revision 12596)
+++ repair.php	(working copy)
@@ -31,35 +31,47 @@
 
 	$okay = true;
 
-	// Loop over the WP tables, checking and repairing as needed.
-	foreach ($wpdb->tables as $table) {
-		if ( in_array($table, $wpdb->old_tables) )
-			continue;
+	//retrieve database tables with WP prefix
+	$tables = $wpdb->get_col( "SHOW TABLES LIKE '".$wpdb->prefix."%'" );
 
-		$check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table");
+	//use only current WP tables
+	$wp_tables = array_diff( $wpdb->tables, $wpdb->old_tables );
+
+	//merge tables which we retrieved from the database with default WP tables
+	foreach( $wp_tables as $wp_table ) {
+		if ( in_array($wpdb->prefix.$wp_table, $tables) == false )
+			array_push ( $tables, $wpdb->prefix.$wp_table );
+	}
+
+	//users can include or exclude tables with the filter 'repair_tables'
+	$tables = apply_filters( 'repair_tables', $tables );
+
+	// Loop over the database tables, checking and repairing as needed.
+	foreach ($tables as $table) {
+		$check = $wpdb->get_row("CHECK TABLE $table");
 		if ( 'OK' == $check->Msg_text ) {
-			echo "<p>The {$wpdb->prefix}$table table is okay.";
+			echo "<p>The $table table is okay.";
 		} 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&hellip;";
-			$repair = $wpdb->get_row("REPAIR TABLE {$wpdb->prefix}$table");
+			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;";
+			$repair = $wpdb->get_row("REPAIR TABLE $table");
 			if ( 'OK' == $check->Msg_text ) {
-				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Sucessfully repaired the {$wpdb->prefix}$table table.";
+				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully repaired the $table table.";
 			} else {
-				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text<br />";
-				$problems["{$wpdb->prefix}$table"] = $check->Msg_text;
+				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the $table table. Error: $check->Msg_text<br />";
+				$problems["$table"] = $check->Msg_text;
 				$okay = false;
 			}
 		}
 		if ( $okay && $optimize ) {
-			$check = $wpdb->get_row("ANALYZE TABLE {$wpdb->prefix}$table");
+			$check = $wpdb->get_row("ANALYZE TABLE $table");
 			if ( 'Table is already up to date' == $check->Msg_text )  {
-				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The {$wpdb->prefix}$table table is already optimized.";
+				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The $table table is already optimized.";
 			} else {
-				$check = $wpdb->get_row("OPTIMIZE TABLE {$wpdb->prefix}$table");
+				$check = $wpdb->get_row("OPTIMIZE TABLE $table");
 				if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text )
-					echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Sucessfully optimized the {$wpdb->prefix}$table table.";
+					echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully optimized the $table table.";
 				else
-					echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the {$wpdb->prefix}$table table. Error: $check->Msg_text";
+					echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the $table table. Error: $check->Msg_text";
 			}
 		}
 		echo '</p>';
