Make WordPress Core

Changeset 32830


Ignore:
Timestamp:
06/18/2015 11:06:09 AM (10 years ago)
Author:
obenland
Message:

Recommend a user updates keys/salts in maint/repair.php.

Since they are already going into wp-config.php, we should also encourage
them to update their unique phrases for keys and salts, assuming they do not
have a complete set of 8 unique ones already.

Props nacin, chriscct7.
Fixes #20779.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/maint/repair.php

    r28896 r32830  
    2929if ( ! defined( 'WP_ALLOW_REPAIR' ) ) {
    3030    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>";
     31
     32    $default_key     = 'put your unique phrase here';
     33    $missing_key     = false;
     34    $duplicated_keys = array();
     35
     36    foreach ( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' ) as $key ) {
     37        if ( defined( $key ) ) {
     38            $duplicated_keys[ constant( $key ) ] = isset( $duplicated_keys[ constant( $key ) ] );
     39        } else {
     40            $missing_key = true;
     41        }
     42    }
     43
     44    if ( isset( $duplicated_keys[ $default_key ] ) ) {
     45        $duplicated_keys[ $default_key ] = true;
     46    }
     47    $duplicated_keys = array_filter( $duplicated_keys );
     48
     49    if ( $duplicated_keys || $missing_key ) {
     50        // Translators: 1: wp-config.php; 2: Secret key service URL.
     51        echo '<p>' . sprintf( __( 'While you are in your %1$s file, you should also make sure you have the 8 unique phrases in place. 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>';
     52    }
     53
    3154} elseif ( isset( $_GET['repair'] ) ) {
    3255    $optimize = 2 == $_GET['repair'];
Note: See TracChangeset for help on using the changeset viewer.