2009-09-06 20:46:27 +02:00
< ? php
2012-01-26 00:27:13 +01:00
/**
* Database Repair and Optimization Script .
*
* @ package WordPress
* @ subpackage Database
*/
2017-12-01 00:11:00 +01:00
define ( 'WP_REPAIRING' , true );
2009-09-06 20:46:27 +02:00
2020-02-06 07:33:11 +01:00
require_once dirname ( dirname ( __DIR__ ) ) . '/wp-load.php' ;
2009-09-06 20:46:27 +02:00
header ( 'Content-Type: text/html; charset=utf-8' );
?>
2011-07-22 02:25:41 +02:00
<! DOCTYPE html >
2020-06-22 23:26:16 +02:00
< html < ? php language_attributes (); ?> >
2009-09-06 20:46:27 +02:00
< head >
2013-11-21 01:21:11 +01:00
< meta name = " viewport " content = " width=device-width " />
2009-09-06 20:46:27 +02:00
< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " />
2015-12-08 22:56:27 +01:00
< meta name = " robots " content = " noindex,nofollow " />
2012-01-26 00:27:13 +01:00
< title >< ? php _e ( 'WordPress › Database Repair' ); ?> </title>
Upgrade/Install: Bring some consistency to installation screen styles.
* Include `forms.css` and `l10n.css`, for consistency with login screen and other admin screens.
* Remove redundant `@import` directives from `login.css` for files already declared as dependencies.
* Adjust margin on password strength meter for consistency with other fields.
* Increase font size for "You will need this password to log in" notice.
* Fix misaligned icon on "Hide" button for the password.
Props iseulde, dan@micamedia.com, bassgang, cdog, johnbillion, nmenescardi, mukesh27, SergeyBiryukov.
Fixes #35776, #47757, #47758.
Built from https://develop.svn.wordpress.org/trunk@45673
git-svn-id: http://core.svn.wordpress.org/trunk@45484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-25 21:11:55 +02:00
< ? php wp_admin_css ( 'install' , true ); ?>
2009-09-06 20:46:27 +02:00
</ head >
2012-11-30 14:40:59 +01:00
< body class = " wp-core-ui " >
2019-01-10 18:21:52 +01:00
< p id = " logo " >< a href = " <?php echo esc_url( __( 'https://wordpress.org/' ) ); ?> " >< ? php _e ( 'WordPress' ); ?> </a></p>
2009-09-06 20:46:27 +02:00
< ? php
2017-11-20 07:21:52 +01:00
if ( ! defined ( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) {
2015-11-04 19:00:24 +01:00
2015-11-04 22:32:26 +01:00
echo '<h1 class="screen-reader-text">' . __ ( 'Allow automatic database repair' ) . '</h1>' ;
2015-11-04 19:00:24 +01:00
2016-06-26 16:26:29 +02:00
echo '<p>' ;
printf (
2016-07-04 15:10:30 +02:00
/* translators: %s: wp-config.php */
2016-06-26 16:26:29 +02:00
__ ( 'To allow use of this page to automatically repair database problems, please add the following line to your %s file. Once this line is added to your config, reload this page.' ),
'<code>wp-config.php</code>'
);
echo " </p><p><code>define('WP_ALLOW_REPAIR', true);</code></p> " ;
2015-06-18 13:07:25 +02:00
2022-10-04 05:59:13 +02:00
$default_keys = array_unique (
array (
'put your unique phrase here' ,
/*
* translators : This string should only be translated if wp - config - sample . php is localized .
* You can check the localized release package or
* https :// i18n . svn . wordpress . org /< locale code >/ branches /< wp version >/ dist / wp - config - sample . php
*/
__ ( 'put your unique phrase here' ),
)
);
2015-06-18 13:07:25 +02:00
$missing_key = false ;
$duplicated_keys = array ();
foreach ( array ( 'AUTH_KEY' , 'SECURE_AUTH_KEY' , 'LOGGED_IN_KEY' , 'NONCE_KEY' , 'AUTH_SALT' , 'SECURE_AUTH_SALT' , 'LOGGED_IN_SALT' , 'NONCE_SALT' ) as $key ) {
if ( defined ( $key ) ) {
2015-07-01 17:39:26 +02:00
// Check for unique values of each key.
2015-06-18 13:07:25 +02:00
$duplicated_keys [ constant ( $key ) ] = isset ( $duplicated_keys [ constant ( $key ) ] );
} else {
2015-07-01 17:39:26 +02:00
// If a constant is not defined, it's missing.
2015-06-18 13:07:25 +02:00
$missing_key = true ;
}
}
2022-10-04 05:59:13 +02:00
// If at least one key uses a default value, consider it duplicated.
foreach ( $default_keys as $default_key ) {
if ( isset ( $duplicated_keys [ $default_key ] ) ) {
$duplicated_keys [ $default_key ] = true ;
}
2015-06-18 13:07:25 +02:00
}
2015-07-01 17:39:26 +02:00
// Weed out all unique, non-default values.
2015-06-18 13:07:25 +02:00
$duplicated_keys = array_filter ( $duplicated_keys );
if ( $duplicated_keys || $missing_key ) {
2015-11-04 19:00:24 +01:00
echo '<h2 class="screen-reader-text">' . __ ( 'Check secret keys' ) . '</h2>' ;
2019-09-03 02:41:05 +02:00
/* translators: 1: wp-config.php, 2: Secret key service URL. */
2015-07-01 17:39:26 +02:00
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>' ;
2015-06-18 13:07:25 +02:00
}
2012-01-26 00:27:13 +01:00
} elseif ( isset ( $_GET [ 'repair' ] ) ) {
2015-11-04 19:00:24 +01:00
2015-11-04 22:32:26 +01:00
echo '<h1 class="screen-reader-text">' . __ ( 'Database repair results' ) . '</h1>' ;
2015-11-04 19:00:24 +01:00
2012-01-26 00:27:13 +01:00
$optimize = 2 == $_GET [ 'repair' ];
2017-12-01 00:11:00 +01:00
$okay = true ;
2011-10-27 20:31:45 +02:00
$problems = array ();
2009-10-22 22:23:19 +02:00
2010-03-01 07:35:48 +01:00
$tables = $wpdb -> tables ();
2011-10-27 20:31:45 +02:00
2010-04-15 23:49:42 +02:00
// Sitecategories may not exist if global terms are disabled.
2017-12-01 00:11:00 +01:00
$query = $wpdb -> prepare ( 'SHOW TABLES LIKE %s' , $wpdb -> esc_like ( $wpdb -> sitecategories ) );
2014-06-10 02:44:15 +02:00
if ( is_multisite () && ! $wpdb -> get_var ( $query ) ) {
2010-04-15 23:49:42 +02:00
unset ( $tables [ 'sitecategories' ] );
2014-06-10 02:44:15 +02:00
}
2011-10-27 20:31:45 +02:00
2013-10-08 02:30:09 +02:00
/**
2016-05-22 20:01:30 +02:00
* Filters additional database tables to repair .
2013-10-08 02:30:09 +02:00
*
* @ since 3.0 . 0
*
2018-03-25 20:10:32 +02:00
* @ param string [] $tables Array of prefixed table names to be repaired .
2013-10-08 02:30:09 +02:00
*/
$tables = array_merge ( $tables , ( array ) apply_filters ( 'tables_to_repair' , array () ) );
2011-10-27 20:31:45 +02:00
2010-03-01 07:35:48 +01:00
// Loop over the tables, checking and repairing as needed.
2010-02-19 15:33:01 +01:00
foreach ( $tables as $table ) {
2012-01-26 00:27:13 +01:00
$check = $wpdb -> get_row ( " CHECK TABLE $table " );
2011-10-27 20:31:45 +02:00
echo '<p>' ;
2020-05-16 20:42:12 +02:00
if ( 'OK' === $check -> Msg_text ) {
2019-09-03 02:41:05 +02:00
/* translators: %s: Table name. */
2012-01-26 00:27:13 +01:00
printf ( __ ( 'The %s table is okay.' ), " <code> $table </code> " );
2009-09-06 20:46:27 +02:00
} else {
2019-09-03 02:41:05 +02:00
/* translators: 1: Table name, 2: Error message. */
2017-12-01 00:11:00 +01:00
printf ( __ ( 'The %1$s table is not okay. It is reporting the following error: %2$s. WordPress will attempt to repair this table…' ), " <code> $table </code> " , " <code> $check->Msg_text </code> " );
2011-10-27 20:31:45 +02:00
2012-01-26 00:27:13 +01:00
$repair = $wpdb -> get_row ( " REPAIR TABLE $table " );
2011-10-27 20:31:45 +02:00
echo '<br /> ' ;
2020-12-04 16:50:12 +01:00
if ( 'OK' === $repair -> Msg_text ) {
2019-09-03 02:41:05 +02:00
/* translators: %s: Table name. */
2012-01-26 00:27:13 +01:00
printf ( __ ( 'Successfully repaired the %s table.' ), " <code> $table </code> " );
2009-09-06 20:46:27 +02:00
} else {
2019-09-03 02:41:05 +02:00
/* translators: 1: Table name, 2: Error message. */
2020-12-04 16:50:12 +01:00
printf ( __ ( 'Failed to repair the %1$s table. Error: %2$s' ), " <code> $table </code> " , " <code> $repair->Msg_text </code> " ) . '<br />' ;
$problems [ $table ] = $repair -> Msg_text ;
2017-12-01 00:11:00 +01:00
$okay = false ;
2009-09-06 20:46:27 +02:00
}
}
2011-10-27 20:31:45 +02:00
2009-10-22 22:23:19 +02:00
if ( $okay && $optimize ) {
2020-12-04 16:50:12 +01:00
$analyze = $wpdb -> get_row ( " ANALYZE TABLE $table " );
2011-10-27 20:31:45 +02:00
2012-01-26 00:27:13 +01:00
echo '<br /> ' ;
2020-12-04 16:50:12 +01:00
if ( 'Table is already up to date' === $analyze -> Msg_text ) {
2019-09-03 02:41:05 +02:00
/* translators: %s: Table name. */
2012-01-26 00:27:13 +01:00
printf ( __ ( 'The %s table is already optimized.' ), " <code> $table </code> " );
2009-10-22 22:23:19 +02:00
} else {
2020-12-04 16:50:12 +01:00
$optimize = $wpdb -> get_row ( " OPTIMIZE TABLE $table " );
2011-10-27 20:31:45 +02:00
2012-01-26 00:27:13 +01:00
echo '<br /> ' ;
2020-12-04 16:50:12 +01:00
if ( 'OK' === $optimize -> Msg_text || 'Table is already up to date' === $optimize -> Msg_text ) {
2019-09-03 02:41:05 +02:00
/* translators: %s: Table name. */
2012-01-26 00:27:13 +01:00
printf ( __ ( 'Successfully optimized the %s table.' ), " <code> $table </code> " );
2011-10-27 20:31:45 +02:00
} else {
2019-09-03 02:41:05 +02:00
/* translators: 1: Table name. 2: Error message. */
2020-12-04 16:50:12 +01:00
printf ( __ ( 'Failed to optimize the %1$s table. Error: %2$s' ), " <code> $table </code> " , " <code> $optimize->Msg_text </code> " );
2011-10-27 20:31:45 +02:00
}
2009-10-22 22:23:19 +02:00
}
}
echo '</p>' ;
2009-09-06 20:46:27 +02:00
}
2012-01-26 00:27:13 +01:00
if ( $problems ) {
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
printf (
2019-09-03 02:41:05 +02:00
/* translators: %s: URL to "Fixing WordPress" forum. */
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
'<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' )
);
2012-01-26 00:27:13 +01:00
$problem_output = '' ;
2017-12-01 00:11:00 +01:00
foreach ( $problems as $table => $problem ) {
2012-01-26 00:27:13 +01:00
$problem_output .= " $table : $problem\n " ;
2017-12-01 00:11:00 +01:00
}
2012-01-26 00:27:13 +01:00
echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea ( $problem_output ) . '</textarea></p>' ;
2009-09-06 20:46:27 +02:00
} else {
2013-11-21 01:21:11 +01:00
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> " ;
2009-09-06 20:46:27 +02:00
}
} else {
2015-11-04 19:00:24 +01:00
echo '<h1 class="screen-reader-text">' . __ ( 'WordPress database repair' ) . '</h1>' ;
2020-05-16 20:42:12 +02:00
if ( isset ( $_GET [ 'referrer' ] ) && 'is_blog_installed' === $_GET [ 'referrer' ] ) {
2012-01-26 00:27:13 +01:00
echo '<p>' . __ ( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the “Repair Database” button. Repairing can take a while, so please be patient.' ) . '</p>' ;
2017-12-01 00:11:00 +01:00
} else {
2012-01-26 00:27:13 +01:00
echo '<p>' . __ ( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>' ;
2017-12-01 00:11:00 +01:00
}
2018-08-17 03:51:36 +02:00
?>
2012-10-26 21:40:39 +02:00
< p class = " step " >< a class = " button button-large " href = " repair.php?repair=1 " >< ? php _e ( 'Repair Database' ); ?> </a></p>
2012-01-26 00:27:13 +01:00
< p >< ? php _e ( 'WordPress can also attempt to optimize the database. This improves performance in some situations. Repairing and optimizing the database can take a long time and the database will be locked while optimizing.' ); ?> </p>
2012-10-26 21:40:39 +02:00
< p class = " step " >< a class = " button button-large " href = " repair.php?repair=2 " >< ? php _e ( 'Repair and Optimize Database' ); ?> </a></p>
2018-08-17 03:51:36 +02:00
< ? php
2009-09-06 20:46:27 +02:00
}
?>
</ body >
2011-07-22 02:25:41 +02:00
</ html >