Ticket #11707: 11707_include_all_tables.diff
File 11707_include_all_tables.diff, 3.3 KB (added by , 11 years ago) |
---|
-
repair.php
31 31 32 32 $okay = true; 33 33 34 // Loop over the WP tables, checking and repairing as needed. 35 foreach ($wpdb->tables as $table) { 36 if ( in_array($table, $wpdb->old_tables) ) 37 continue; 34 //retrieve database tables with WP prefix 35 $tables = $wpdb->get_col( "SHOW TABLES" ); 38 36 39 $check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table"); 37 //use only current WP tables 38 $wp_tables = array_diff( $wpdb->tables, $wpdb->old_tables ); 39 40 //merge tables which we retrieved from the database with default WP tables 41 foreach( $wp_tables as $wp_table ) { 42 if ( in_array($wpdb->prefix.$wp_table, $tables) == false ) 43 array_push ( $tables, $wpdb->prefix.$wp_table ); 44 } 45 46 //users can include or exclude tables with the filter 'repair_tables' 47 $tables = apply_filters( 'repair_tables', $tables ); 48 49 // Loop over the database tables, checking and repairing as needed. 50 foreach ($tables as $table) { 51 $check = $wpdb->get_row("CHECK TABLE $table"); 40 52 if ( 'OK' == $check->Msg_text ) { 41 echo "<p>The {$wpdb->prefix}$table table is okay.";53 echo "<p>The $table table is okay."; 42 54 } 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…";44 $repair = $wpdb->get_row("REPAIR TABLE {$wpdb->prefix}$table");55 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…"; 56 $repair = $wpdb->get_row("REPAIR TABLE $table"); 45 57 if ( 'OK' == $check->Msg_text ) { 46 echo "<br /> Suc essfully repaired the {$wpdb->prefix}$table table.";58 echo "<br /> Successfully repaired the $table table."; 47 59 } else { 48 echo "<br /> Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text<br />";49 $problems[" {$wpdb->prefix}$table"] = $check->Msg_text;60 echo "<br /> Failed to repair the $table table. Error: $check->Msg_text<br />"; 61 $problems["$table"] = $check->Msg_text; 50 62 $okay = false; 51 63 } 52 64 } 53 65 if ( $okay && $optimize ) { 54 $check = $wpdb->get_row("ANALYZE TABLE {$wpdb->prefix}$table");66 $check = $wpdb->get_row("ANALYZE TABLE $table"); 55 67 if ( 'Table is already up to date' == $check->Msg_text ) { 56 echo "<br /> The {$wpdb->prefix}$table table is already optimized.";68 echo "<br /> The $table table is already optimized."; 57 69 } else { 58 $check = $wpdb->get_row("OPTIMIZE TABLE {$wpdb->prefix}$table");70 $check = $wpdb->get_row("OPTIMIZE TABLE $table"); 59 71 if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) 60 echo "<br /> Suc essfully optimized the {$wpdb->prefix}$table table.";72 echo "<br /> Successfully optimized the $table table."; 61 73 else 62 echo "<br /> Failed to optimize the {$wpdb->prefix}$table table. Error: $check->Msg_text";74 echo "<br /> Failed to optimize the $table table. Error: $check->Msg_text"; 63 75 } 64 76 } 65 77 echo '</p>';