wp/wp-admin/maint/repair.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Database
     6  * @subpackage Database
     7  */
     7  */
     8 define( 'WP_REPAIRING', true );
     8 define( 'WP_REPAIRING', true );
     9 
     9 
    10 require_once( dirname( dirname( dirname( __FILE__ ) ) ) . '/wp-load.php' );
    10 require_once dirname( dirname( __DIR__ ) ) . '/wp-load.php';
    11 
    11 
    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 <?php language_attributes(); ?>>
    16 <head>
    16 <head>
    17 	<meta name="viewport" content="width=device-width" />
    17 	<meta name="viewport" content="width=device-width" />
    18 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    18 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    19 	<meta name="robots" content="noindex,nofollow" />
    19 	<meta name="robots" content="noindex,nofollow" />
    20 	<title><?php _e( 'WordPress &rsaquo; Database Repair' ); ?></title>
    20 	<title><?php _e( 'WordPress &rsaquo; Database Repair' ); ?></title>
    61 
    61 
    62 	if ( $duplicated_keys || $missing_key ) {
    62 	if ( $duplicated_keys || $missing_key ) {
    63 
    63 
    64 		echo '<h2 class="screen-reader-text">' . __( 'Check secret keys' ) . '</h2>';
    64 		echo '<h2 class="screen-reader-text">' . __( 'Check secret keys' ) . '</h2>';
    65 
    65 
    66 		/* translators: 1: wp-config.php, 2: secret key service URL */
    66 		/* translators: 1: wp-config.php, 2: Secret key service URL. */
    67 		echo '<p>' . sprintf( __( 'While you are editing your %1$s file, take a moment to make sure you have all 8 keys and that they are unique. You can generate these using the <a href="%2$s">WordPress.org secret key service</a>.' ), '<code>wp-config.php</code>', 'https://api.wordpress.org/secret-key/1.1/salt/' ) . '</p>';
    67 		echo '<p>' . sprintf( __( 'While you are editing your %1$s file, take a moment to make sure you have all 8 keys and that they are unique. You can generate these using the <a href="%2$s">WordPress.org secret key service</a>.' ), '<code>wp-config.php</code>', 'https://api.wordpress.org/secret-key/1.1/salt/' ) . '</p>';
    68 	}
    68 	}
    69 } elseif ( isset( $_GET['repair'] ) ) {
    69 } elseif ( isset( $_GET['repair'] ) ) {
    70 
    70 
    71 	echo '<h1 class="screen-reader-text">' . __( 'Database repair results' ) . '</h1>';
    71 	echo '<h1 class="screen-reader-text">' . __( 'Database repair results' ) . '</h1>';
    94 	// Loop over the tables, checking and repairing as needed.
    94 	// Loop over the tables, checking and repairing as needed.
    95 	foreach ( $tables as $table ) {
    95 	foreach ( $tables as $table ) {
    96 		$check = $wpdb->get_row( "CHECK TABLE $table" );
    96 		$check = $wpdb->get_row( "CHECK TABLE $table" );
    97 
    97 
    98 		echo '<p>';
    98 		echo '<p>';
    99 		if ( 'OK' == $check->Msg_text ) {
    99 		if ( 'OK' === $check->Msg_text ) {
   100 			/* translators: %s: table name */
   100 			/* translators: %s: Table name. */
   101 			printf( __( 'The %s table is okay.' ), "<code>$table</code>" );
   101 			printf( __( 'The %s table is okay.' ), "<code>$table</code>" );
   102 		} else {
   102 		} else {
   103 			/* translators: 1: table name, 2: error message, */
   103 			/* translators: 1: Table name, 2: Error message. */
   104 			printf( __( 'The %1$s table is not okay. It is reporting the following error: %2$s. WordPress will attempt to repair this table&hellip;' ), "<code>$table</code>", "<code>$check->Msg_text</code>" );
   104 			printf( __( 'The %1$s table is not okay. It is reporting the following error: %2$s. WordPress will attempt to repair this table&hellip;' ), "<code>$table</code>", "<code>$check->Msg_text</code>" );
   105 
   105 
   106 			$repair = $wpdb->get_row( "REPAIR TABLE $table" );
   106 			$repair = $wpdb->get_row( "REPAIR TABLE $table" );
   107 
   107 
   108 			echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
   108 			echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
   109 			if ( 'OK' == $check->Msg_text ) {
   109 			if ( 'OK' === $check->Msg_text ) {
   110 				/* translators: %s: table name */
   110 				/* translators: %s: Table name. */
   111 				printf( __( 'Successfully repaired the %s table.' ), "<code>$table</code>" );
   111 				printf( __( 'Successfully repaired the %s table.' ), "<code>$table</code>" );
   112 			} else {
   112 			} else {
   113 				/* translators: 1: table name, 2: error message, */
   113 				/* translators: 1: Table name, 2: Error message. */
   114 				echo sprintf( __( 'Failed to repair the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" ) . '<br />';
   114 				printf( __( 'Failed to repair the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" ) . '<br />';
   115 				$problems[ $table ] = $check->Msg_text;
   115 				$problems[ $table ] = $check->Msg_text;
   116 				$okay               = false;
   116 				$okay               = false;
   117 			}
   117 			}
   118 		}
   118 		}
   119 
   119 
   120 		if ( $okay && $optimize ) {
   120 		if ( $okay && $optimize ) {
   121 			$check = $wpdb->get_row( "ANALYZE TABLE $table" );
   121 			$check = $wpdb->get_row( "ANALYZE TABLE $table" );
   122 
   122 
   123 			echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
   123 			echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
   124 			if ( 'Table is already up to date' == $check->Msg_text ) {
   124 			if ( 'Table is already up to date' === $check->Msg_text ) {
   125 				/* translators: %s: table name */
   125 				/* translators: %s: Table name. */
   126 				printf( __( 'The %s table is already optimized.' ), "<code>$table</code>" );
   126 				printf( __( 'The %s table is already optimized.' ), "<code>$table</code>" );
   127 			} else {
   127 			} else {
   128 				$check = $wpdb->get_row( "OPTIMIZE TABLE $table" );
   128 				$check = $wpdb->get_row( "OPTIMIZE TABLE $table" );
   129 
   129 
   130 				echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
   130 				echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
   131 				if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) {
   131 				if ( 'OK' === $check->Msg_text || 'Table is already up to date' === $check->Msg_text ) {
   132 					/* translators: %s: table name */
   132 					/* translators: %s: Table name. */
   133 					printf( __( 'Successfully optimized the %s table.' ), "<code>$table</code>" );
   133 					printf( __( 'Successfully optimized the %s table.' ), "<code>$table</code>" );
   134 				} else {
   134 				} else {
   135 					/* translators: 1: table name, 2: error message, */
   135 					/* translators: 1: Table name. 2: Error message. */
   136 					printf( __( 'Failed to optimize the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" );
   136 					printf( __( 'Failed to optimize the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" );
   137 				}
   137 				}
   138 			}
   138 			}
   139 		}
   139 		}
   140 		echo '</p>';
   140 		echo '</p>';
   141 	}
   141 	}
   142 
   142 
   143 	if ( $problems ) {
   143 	if ( $problems ) {
   144 		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' ) );
   144 		printf(
       
   145 			/* translators: %s: URL to "Fixing WordPress" forum. */
       
   146 			'<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>',
       
   147 			__( 'https://wordpress.org/support/forum/how-to-and-troubleshooting' )
       
   148 		);
   145 		$problem_output = '';
   149 		$problem_output = '';
   146 		foreach ( $problems as $table => $problem ) {
   150 		foreach ( $problems as $table => $problem ) {
   147 			$problem_output .= "$table: $problem\n";
   151 			$problem_output .= "$table: $problem\n";
   148 		}
   152 		}
   149 		echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( $problem_output ) . '</textarea></p>';
   153 		echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( $problem_output ) . '</textarea></p>';
   152 	}
   156 	}
   153 } else {
   157 } else {
   154 
   158 
   155 	echo '<h1 class="screen-reader-text">' . __( 'WordPress database repair' ) . '</h1>';
   159 	echo '<h1 class="screen-reader-text">' . __( 'WordPress database repair' ) . '</h1>';
   156 
   160 
   157 	if ( isset( $_GET['referrer'] ) && 'is_blog_installed' == $_GET['referrer'] ) {
   161 	if ( isset( $_GET['referrer'] ) && 'is_blog_installed' === $_GET['referrer'] ) {
   158 		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>';
   162 		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>';
   159 	} else {
   163 	} else {
   160 		echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>';
   164 		echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>';
   161 	}
   165 	}
   162 	?>
   166 	?>