wp/wp-admin/maint/repair.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    12 header( 'Content-Type: text/html; charset=utf-8' );
    12 header( 'Content-Type: text/html; charset=utf-8' );
    13 ?>
    13 ?>
    14 <!DOCTYPE html>
    14 <!DOCTYPE html>
    15 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    15 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    16 <head>
    16 <head>
       
    17 	<meta name="viewport" content="width=device-width" />
    17 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    18 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    18 	<title><?php _e( 'WordPress &rsaquo; Database Repair' ); ?></title>
    19 	<title><?php _e( 'WordPress &rsaquo; Database Repair' ); ?></title>
    19 	<?php
    20 	<?php
    20 	wp_admin_css( 'install', true );
    21 	wp_admin_css( 'install', true );
    21 	?>
    22 	?>
    22 </head>
    23 </head>
    23 <body class="wp-core-ui">
    24 <body class="wp-core-ui">
    24 <h1 id="logo"><a href="<?php echo esc_url( __( 'http://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
    25 <h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1>
    25 
    26 
    26 <?php
    27 <?php
    27 
    28 
    28 if ( ! defined( 'WP_ALLOW_REPAIR' ) ) {
    29 if ( ! defined( 'WP_ALLOW_REPAIR' ) ) {
    29 	echo '<p>' . __( 'To allow use of this page to automatically repair database problems, please add the following line to your <code>wp-config.php</code> file. Once this line is added to your config, reload this page.' ) . "</p><code>define('WP_ALLOW_REPAIR', true);</code>";
    30 	echo '<p>' . __( 'To allow use of this page to automatically repair database problems, please add the following line to your <code>wp-config.php</code> file. Once this line is added to your config, reload this page.' ) . "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>";
    30 } elseif ( isset( $_GET['repair'] ) ) {
    31 } elseif ( isset( $_GET['repair'] ) ) {
    31 	$optimize = 2 == $_GET['repair'];
    32 	$optimize = 2 == $_GET['repair'];
    32 	$okay = true;
    33 	$okay = true;
    33 	$problems = array();
    34 	$problems = array();
    34 
    35 
    35 	$tables = $wpdb->tables();
    36 	$tables = $wpdb->tables();
    36 
    37 
    37 	// Sitecategories may not exist if global terms are disabled.
    38 	// Sitecategories may not exist if global terms are disabled.
    38 	if ( is_multisite() && ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->sitecategories'" ) )
    39 	$query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->sitecategories ) );
       
    40 	if ( is_multisite() && ! $wpdb->get_var( $query ) ) {
    39 		unset( $tables['sitecategories'] );
    41 		unset( $tables['sitecategories'] );
       
    42 	}
    40 
    43 
    41 	/**
    44 	/**
    42 	 * Filter additional database tables to repair.
    45 	 * Filter additional database tables to repair.
    43 	 *
    46 	 *
    44 	 * @since 3.0.0
    47 	 * @since 3.0.0
    95 		}
    98 		}
    96 		echo '</p>';
    99 		echo '</p>';
    97 	}
   100 	}
    98 
   101 
    99 	if ( $problems ) {
   102 	if ( $problems ) {
   100 		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/how-to-and-troubleshooting' ) );
   103 		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>', __( 'https://wordpress.org/support/forum/how-to-and-troubleshooting' ) );
   101 		$problem_output = '';
   104 		$problem_output = '';
   102 		foreach ( $problems as $table => $problem )
   105 		foreach ( $problems as $table => $problem )
   103 			$problem_output .= "$table: $problem\n";
   106 			$problem_output .= "$table: $problem\n";
   104 		echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( $problem_output ) . '</textarea></p>';
   107 		echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( $problem_output ) . '</textarea></p>';
   105 	} else {
   108 	} else {
   106 		echo '<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('WP_ALLOW_REPAIR', true);</code>";
   109 		echo '<p>' . __( 'Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.' ) . "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>";
   107 	}
   110 	}
   108 } else {
   111 } else {
   109 	if ( isset( $_GET['referrer'] ) && 'is_blog_installed' == $_GET['referrer'] )
   112 	if ( isset( $_GET['referrer'] ) && 'is_blog_installed' == $_GET['referrer'] )
   110 		echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the &#8220;Repair Database&#8221; button. Repairing can take a while, so please be patient.' ) . '</p>';
   113 		echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the &#8220;Repair Database&#8221; button. Repairing can take a while, so please be patient.' ) . '</p>';
   111 	else
   114 	else