| 1 | Index: wp-includes/functions.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/functions.php (revision 11901) |
|---|
| 4 | +++ wp-includes/functions.php (working copy) |
|---|
| 5 | @@ -1771,7 +1771,31 @@ |
|---|
| 6 | $installed = !empty( $installed ); |
|---|
| 7 | wp_cache_set( 'is_blog_installed', $installed ); |
|---|
| 8 | |
|---|
| 9 | - return $installed; |
|---|
| 10 | + if ( $installed ) |
|---|
| 11 | + return true; |
|---|
| 12 | + |
|---|
| 13 | + $suppress = $wpdb->suppress_errors(); |
|---|
| 14 | + $tables = $wpdb->get_col('SHOW TABLES'); |
|---|
| 15 | + $wpdb->suppress_errors( $suppress ); |
|---|
| 16 | + |
|---|
| 17 | + // Loop over the WP tables. If none exist, then scratch install is allowed. |
|---|
| 18 | + // If one or more exist, suggest table repair since we got here because the options |
|---|
| 19 | + // table could not be accessed. |
|---|
| 20 | + foreach ($wpdb->tables as $table) { |
|---|
| 21 | + // If one of the WP tables exist, then we are in an insane state. |
|---|
| 22 | + if ( in_array($wpdb->prefix . $table, $tables) ) { |
|---|
| 23 | + // If visiting repair.php, return true and let it take over. |
|---|
| 24 | + if ( defined('WP_REPAIRING') ) |
|---|
| 25 | + return true; |
|---|
| 26 | + // Die with a DB error. |
|---|
| 27 | + $wpdb->error = __('One or more database tables are unavailable. The database may need to be <a href="maint/repair.php?referrer=is_blog_installed">repaired</a>.'); |
|---|
| 28 | + dead_db(); |
|---|
| 29 | + } |
|---|
| 30 | + } |
|---|
| 31 | + |
|---|
| 32 | + wp_cache_set( 'is_blog_installed', false ); |
|---|
| 33 | + |
|---|
| 34 | + return false; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | /** |
|---|
| 38 | Index: wp-includes/wp-db.php |
|---|
| 39 | =================================================================== |
|---|
| 40 | --- wp-includes/wp-db.php (revision 11901) |
|---|
| 41 | +++ wp-includes/wp-db.php (working copy) |
|---|
| 42 | @@ -255,6 +255,16 @@ |
|---|
| 43 | 'postmeta', 'terms', 'term_taxonomy', 'term_relationships'); |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | + * List of deprecated WordPress tables |
|---|
| 47 | + * |
|---|
| 48 | + * @since 2.9.0 |
|---|
| 49 | + * @access private |
|---|
| 50 | + * @var array |
|---|
| 51 | + */ |
|---|
| 52 | + var $old_tables = array('categories', 'post2cat', 'link2cat'); |
|---|
| 53 | + |
|---|
| 54 | + |
|---|
| 55 | + /** |
|---|
| 56 | * Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php. |
|---|
| 57 | * |
|---|
| 58 | * Keys are colmn names, values are format types: 'ID' => '%d' |
|---|
| 59 | Index: wp-admin/maint/repair.php |
|---|
| 60 | =================================================================== |
|---|
| 61 | --- wp-admin/maint/repair.php (revision 0) |
|---|
| 62 | +++ wp-admin/maint/repair.php (revision 0) |
|---|
| 63 | @@ -0,0 +1,68 @@ |
|---|
| 64 | +<?php |
|---|
| 65 | + |
|---|
| 66 | +define('WP_REPAIRING', true); |
|---|
| 67 | + |
|---|
| 68 | +require_once('../../wp-load.php'); |
|---|
| 69 | + |
|---|
| 70 | +header( 'Content-Type: text/html; charset=utf-8' ); |
|---|
| 71 | +?> |
|---|
| 72 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 73 | +<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> |
|---|
| 74 | +<head> |
|---|
| 75 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 76 | + <title><?php _e('WordPress › Database Repair'); ?></title> |
|---|
| 77 | + <?php wp_admin_css( 'install', true ); ?> |
|---|
| 78 | +</head> |
|---|
| 79 | +<body> |
|---|
| 80 | +<h1 id="logo"><img alt="WordPress" src="../images/wordpress-logo.png" /></h1> |
|---|
| 81 | + |
|---|
| 82 | +<?php |
|---|
| 83 | + |
|---|
| 84 | +if ( !defined('REPAIR') ) { |
|---|
| 85 | + _e("<p>To allow use of this page to automatically repair database problems, please add the following line to your wp-config.php file. Once this line is added to your config, reload this page.</p><code>define('REPAIR', true);</code>"); |
|---|
| 86 | +} elseif ( isset($_GET['repair']) ) { |
|---|
| 87 | + $problems = array(); |
|---|
| 88 | + check_admin_referer('repair_db'); |
|---|
| 89 | + |
|---|
| 90 | + // Loop over the WP tables, checking and repairing as needed. |
|---|
| 91 | + foreach ($wpdb->tables as $table) { |
|---|
| 92 | + if ( in_array($table, $wpdb->old_tables) ) |
|---|
| 93 | + continue; |
|---|
| 94 | + |
|---|
| 95 | + $check = $wpdb->get_row("CHECK TABLE {$wpdb->prefix}$table"); |
|---|
| 96 | + if ( 'OK' == $check->Msg_text ) { |
|---|
| 97 | + echo "<p>The {$wpdb->prefix}$table table is okay.</p>"; |
|---|
| 98 | + } else { |
|---|
| 99 | + 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…<br/>"; |
|---|
| 100 | + $repair = $wpdb->get_row("REPAIR TABLE {$wpb->prefix}$table"); |
|---|
| 101 | + if ( 'OK' == $check->Msg_text ) { |
|---|
| 102 | + echo " Sucessfully repaired the {$wpb->prefix}$table table.<br />"; |
|---|
| 103 | + } else { |
|---|
| 104 | + echo " Failed to repair the {$wpdb->prefix}$table table. Error: $check->Msg_text<br />"; |
|---|
| 105 | + $problems["{$wpdb->prefix}$table"] = $check->Msg_text; |
|---|
| 106 | + } |
|---|
| 107 | + } |
|---|
| 108 | + } |
|---|
| 109 | + |
|---|
| 110 | + if ( !empty($problems) ) { |
|---|
| 111 | + printf(__('<p>Some database problems could not be repaired. Please copy-and-paste the following list of errors to the <a href="%s">WordPress support forums</a> to get additional assistance.</p>'), 'http://wordpress.org/support/forum/3'); |
|---|
| 112 | + $problem_output = array(); |
|---|
| 113 | + foreach ( $problems as $table => $problem ) |
|---|
| 114 | + $problem_output[] = "$table: $problem"; |
|---|
| 115 | + echo '<textarea name="errors" id="errors" rows="20" cols="60">' . format_to_edit(implode("\n", $problem_output)) . '</textarea>'; |
|---|
| 116 | + } else { |
|---|
| 117 | + _e("<p>Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.</p><code>define('REPAIR', true);</code>"); |
|---|
| 118 | + } |
|---|
| 119 | +} else { |
|---|
| 120 | + if ( isset($_GET['referrer']) && 'is_blog_installed' == $_GET['referrer'] ) |
|---|
| 121 | + _e('One or more database tables is unavailable. To allow WordPress to attempt to repair these tables, press the "Repair Database" button. Repairing can take awhile, so please be patient.'); |
|---|
| 122 | + else |
|---|
| 123 | + _e('WordPress can automatically look for some common database problems and repair them. Repairing can take awhile, so please be patient.') |
|---|
| 124 | +?> |
|---|
| 125 | + <p class="step"><a class="button" href="<?php echo wp_nonce_url('repair.php?repair=1', 'repair_db') ?>"><?php _e( 'Repair Database' ); ?></a></p> |
|---|
| 126 | +<?php |
|---|
| 127 | +} |
|---|
| 128 | + |
|---|
| 129 | +?> |
|---|
| 130 | +</body> |
|---|
| 131 | +</html> |
|---|
| 132 | \ No newline at end of file |
|---|
| 133 | |
|---|
| 134 | Property changes on: wp-admin/maint/repair.php |
|---|
| 135 | ___________________________________________________________________ |
|---|
| 136 | Added: svn:eol-style |
|---|
| 137 | + native |
|---|
| 138 | |
|---|