2009-09-06 14:46:27 -04:00
< ? php
2012-01-25 18:27:13 -05:00
/**
* Database Repair and Optimization Script .
*
* @ package WordPress
* @ subpackage Database
*/
2017-11-30 18:11:00 -05:00
define ( 'WP_REPAIRING' , true );
2009-09-06 14:46:27 -04:00
2023-09-11 00:53:22 -04:00
require_once dirname ( __DIR__ , 2 ) . '/wp-load.php' ;
2009-09-06 14:46:27 -04:00
header ( 'Content-Type: text/html; charset=utf-8' );
?>
2011-07-21 20:25:41 -04:00
<! DOCTYPE html >
2020-06-22 17:26:16 -04:00
< html < ? php language_attributes (); ?> >
2009-09-06 14:46:27 -04:00
< head >
2024-09-16 20:03:54 -04:00
< meta name = " viewport " content = " width=device-width, initial-scale=1.0 " />
2009-09-06 14:46:27 -04:00
< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " />
2015-12-08 16:56:27 -05:00
< meta name = " robots " content = " noindex,nofollow " />
2012-01-25 18:27:13 -05: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 15:11:55 -04:00
< ? php wp_admin_css ( 'install' , true ); ?>
2009-09-06 14:46:27 -04:00
</ head >
2012-11-30 08:40:59 -05:00
< body class = " wp-core-ui " >
2019-01-10 12:21:52 -05:00
< p id = " logo " >< a href = " <?php echo esc_url( __( 'https://wordpress.org/' ) ); ?> " >< ? php _e ( 'WordPress' ); ?> </a></p>
2009-09-06 14:46:27 -04:00
< ? php
2017-11-20 01:21:52 -05:00
if ( ! defined ( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) {
2015-11-04 13:00:24 -05:00
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
echo '<h1 class="screen-reader-text">' .
/* translators: Hidden accessibility text. */
__ ( 'Allow automatic database repair' ) .
'</h1>' ;
2015-11-04 13:00:24 -05:00
2016-06-26 10:26:29 -04:00
echo '<p>' ;
printf (
2016-07-04 09:10:30 -04:00
/* translators: %s: wp-config.php */
2016-06-26 10:26:29 -04: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 07:07:25 -04:00
2022-10-03 23:59:13 -04: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 07:07:25 -04: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 11:39:26 -04:00
// Check for unique values of each key.
2015-06-18 07:07:25 -04:00
$duplicated_keys [ constant ( $key ) ] = isset ( $duplicated_keys [ constant ( $key ) ] );
} else {
2015-07-01 11:39:26 -04:00
// If a constant is not defined, it's missing.
2015-06-18 07:07:25 -04:00
$missing_key = true ;
}
}
2022-10-03 23:59:13 -04: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 07:07:25 -04:00
}
2015-07-01 11:39:26 -04:00
// Weed out all unique, non-default values.
2015-06-18 07:07:25 -04:00
$duplicated_keys = array_filter ( $duplicated_keys );
if ( $duplicated_keys || $missing_key ) {
2015-11-04 13:00:24 -05:00
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
echo '<h2 class="screen-reader-text">' .
/* translators: Hidden accessibility text. */
__ ( 'Check secret keys' ) .
'</h2>' ;
2015-11-04 13:00:24 -05:00
2019-09-02 20:41:05 -04:00
/* translators: 1: wp-config.php, 2: Secret key service URL. */
2015-07-01 11:39:26 -04: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 07:07:25 -04:00
}
2012-01-25 18:27:13 -05:00
} elseif ( isset ( $_GET [ 'repair' ] ) ) {
2015-11-04 13:00:24 -05:00
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
echo '<h1 class="screen-reader-text">' .
/* translators: Hidden accessibility text. */
__ ( 'Database repair results' ) .
'</h1>' ;
2015-11-04 13:00:24 -05:00
2023-04-11 12:30:22 -04:00
$optimize = '2' === $_GET [ 'repair' ];
2017-11-30 18:11:00 -05:00
$okay = true ;
2011-10-27 14:31:45 -04:00
$problems = array ();
2009-10-22 16:23:19 -04:00
2010-03-01 01:35:48 -05:00
$tables = $wpdb -> tables ();
2011-10-27 14:31:45 -04:00
2013-10-07 20:30:09 -04:00
/**
2016-05-22 14:01:30 -04:00
* Filters additional database tables to repair .
2013-10-07 20:30:09 -04:00
*
* @ since 3.0 . 0
*
2018-03-25 14:10:32 -04:00
* @ param string [] $tables Array of prefixed table names to be repaired .
2013-10-07 20:30:09 -04:00
*/
$tables = array_merge ( $tables , ( array ) apply_filters ( 'tables_to_repair' , array () ) );
2011-10-27 14:31:45 -04:00
2010-03-01 01:35:48 -05:00
// Loop over the tables, checking and repairing as needed.
2010-02-19 09:33:01 -05:00
foreach ( $tables as $table ) {
2012-01-25 18:27:13 -05:00
$check = $wpdb -> get_row ( " CHECK TABLE $table " );
2011-10-27 14:31:45 -04:00
echo '<p>' ;
2020-05-16 14:42:12 -04:00
if ( 'OK' === $check -> Msg_text ) {
2019-09-02 20:41:05 -04:00
/* translators: %s: Table name. */
2012-01-25 18:27:13 -05:00
printf ( __ ( 'The %s table is okay.' ), " <code> $table </code> " );
2009-09-06 14:46:27 -04:00
} else {
2019-09-02 20:41:05 -04:00
/* translators: 1: Table name, 2: Error message. */
2017-11-30 18:11:00 -05: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 14:31:45 -04:00
2012-01-25 18:27:13 -05:00
$repair = $wpdb -> get_row ( " REPAIR TABLE $table " );
2011-10-27 14:31:45 -04:00
echo '<br /> ' ;
2020-12-04 10:50:12 -05:00
if ( 'OK' === $repair -> Msg_text ) {
2019-09-02 20:41:05 -04:00
/* translators: %s: Table name. */
2012-01-25 18:27:13 -05:00
printf ( __ ( 'Successfully repaired the %s table.' ), " <code> $table </code> " );
2009-09-06 14:46:27 -04:00
} else {
2019-09-02 20:41:05 -04:00
/* translators: 1: Table name, 2: Error message. */
2020-12-04 10:50:12 -05: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-11-30 18:11:00 -05:00
$okay = false ;
2009-09-06 14:46:27 -04:00
}
}
2011-10-27 14:31:45 -04:00
2009-10-22 16:23:19 -04:00
if ( $okay && $optimize ) {
2020-12-04 10:50:12 -05:00
$analyze = $wpdb -> get_row ( " ANALYZE TABLE $table " );
2011-10-27 14:31:45 -04:00
2012-01-25 18:27:13 -05:00
echo '<br /> ' ;
2020-12-04 10:50:12 -05:00
if ( 'Table is already up to date' === $analyze -> Msg_text ) {
2019-09-02 20:41:05 -04:00
/* translators: %s: Table name. */
2012-01-25 18:27:13 -05:00
printf ( __ ( 'The %s table is already optimized.' ), " <code> $table </code> " );
2009-10-22 16:23:19 -04:00
} else {
2020-12-04 10:50:12 -05:00
$optimize = $wpdb -> get_row ( " OPTIMIZE TABLE $table " );
2011-10-27 14:31:45 -04:00
2012-01-25 18:27:13 -05:00
echo '<br /> ' ;
2020-12-04 10:50:12 -05:00
if ( 'OK' === $optimize -> Msg_text || 'Table is already up to date' === $optimize -> Msg_text ) {
2019-09-02 20:41:05 -04:00
/* translators: %s: Table name. */
2012-01-25 18:27:13 -05:00
printf ( __ ( 'Successfully optimized the %s table.' ), " <code> $table </code> " );
2011-10-27 14:31:45 -04:00
} else {
2019-09-02 20:41:05 -04:00
/* translators: 1: Table name. 2: Error message. */
2020-12-04 10:50:12 -05:00
printf ( __ ( 'Failed to optimize the %1$s table. Error: %2$s' ), " <code> $table </code> " , " <code> $optimize->Msg_text </code> " );
2011-10-27 14:31:45 -04:00
}
2009-10-22 16:23:19 -04:00
}
}
echo '</p>' ;
2009-09-06 14:46:27 -04:00
}
2012-01-25 18:27:13 -05: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 13:13:59 -04:00
printf (
2019-09-02 20:41:05 -04: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 13:13:59 -04: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-25 18:27:13 -05:00
$problem_output = '' ;
2017-11-30 18:11:00 -05:00
foreach ( $problems as $table => $problem ) {
2012-01-25 18:27:13 -05:00
$problem_output .= " $table : $problem\n " ;
2017-11-30 18:11:00 -05:00
}
2012-01-25 18:27:13 -05:00
echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea ( $problem_output ) . '</textarea></p>' ;
2009-09-06 14:46:27 -04:00
} else {
2013-11-20 19:21:11 -05: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 14:46:27 -04:00
}
} else {
2015-11-04 13:00:24 -05:00
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
echo '<h1 class="screen-reader-text">' .
/* translators: Hidden accessibility text. */
__ ( 'WordPress database repair' ) .
'</h1>' ;
2015-11-04 13:00:24 -05:00
2020-05-16 14:42:12 -04:00
if ( isset ( $_GET [ 'referrer' ] ) && 'is_blog_installed' === $_GET [ 'referrer' ] ) {
2012-01-25 18:27:13 -05: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-11-30 18:11:00 -05:00
} else {
2012-01-25 18:27:13 -05: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-11-30 18:11:00 -05:00
}
2018-08-16 21:51:36 -04:00
?>
2012-10-26 15:40:39 -04:00
< p class = " step " >< a class = " button button-large " href = " repair.php?repair=1 " >< ? php _e ( 'Repair Database' ); ?> </a></p>
2012-01-25 18:27:13 -05: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 15:40:39 -04:00
< p class = " step " >< a class = " button button-large " href = " repair.php?repair=2 " >< ? php _e ( 'Repair and Optimize Database' ); ?> </a></p>
2018-08-16 21:51:36 -04:00
< ? php
2009-09-06 14:46:27 -04:00
}
?>
</ body >
2011-07-21 20:25:41 -04:00
</ html >