Make WordPress Core

Ticket #27881: wp-salt.diff

File wp-salt.diff, 2.9 KB (added by wonderboymusic, 11 years ago)
  • src/wp-includes/pluggable.php

     
    17461746                $duplicated_keys = array( 'put your unique phrase here' => true );
    17471747                foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) {
    17481748                        foreach ( array( 'KEY', 'SALT' ) as $second ) {
    1749                                 if ( ! defined( "{$first}_{$second}" ) )
     1749                                if ( ! defined( "{$first}_{$second}" ) ) {
    17501750                                        continue;
     1751                                }
    17511752                                $value = constant( "{$first}_{$second}" );
    17521753                                $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] );
    17531754                        }
     
    17541755                }
    17551756        }
    17561757
    1757         $key = $salt = '';
    1758         if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) )
    1759                 $key = SECRET_KEY;
    1760         if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) )
    1761                 $salt = SECRET_SALT;
     1758        $values = array(
     1759                'key' => '',
     1760                'salt' => ''
     1761        );
     1762        if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) {
     1763                $values['key'] = SECRET_KEY;
     1764        }
     1765        if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) {
     1766                $values['salt'] = SECRET_SALT;
     1767        }
    17621768
    17631769        if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) {
    17641770                foreach ( array( 'key', 'salt' ) as $type ) {
    17651771                        $const = strtoupper( "{$scheme}_{$type}" );
    17661772                        if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) {
    1767                                 $$type = constant( $const );
    1768                         } elseif ( ! $$type ) {
    1769                                 $$type = get_site_option( "{$scheme}_{$type}" );
    1770                                 if ( ! $$type ) {
    1771                                         $$type = wp_generate_password( 64, true, true );
    1772                                         update_site_option( "{$scheme}_{$type}", $$type );
     1773                                $values[ $type ] = constant( $const );
     1774                        } elseif ( ! $values[ $type ] ) {
     1775                                $values[ $type ] = get_site_option( "{$scheme}_{$type}" );
     1776                                if ( ! $values[ $type ] ) {
     1777                                        $values[ $type ] = wp_generate_password( 64, true, true );
     1778                                        update_site_option( "{$scheme}_{$type}", $values[ $type ] );
    17731779                                }
    17741780                        }
    17751781                }
    17761782        } else {
    1777                 if ( ! $key ) {
    1778                         $key = get_site_option( 'secret_key' );
    1779                         if ( ! $key ) {
    1780                                 $key = wp_generate_password( 64, true, true );
    1781                                 update_site_option( 'secret_key', $key );
     1783                if ( ! $values['key'] ) {
     1784                        $values['key'] = get_site_option( 'secret_key' );
     1785                        if ( ! $values['key'] ) {
     1786                                $values['key'] = wp_generate_password( 64, true, true );
     1787                                update_site_option( 'secret_key', $values['key'] );
    17821788                        }
    17831789                }
    1784                 $salt = hash_hmac( 'md5', $scheme, $key );
     1790                $values['salt'] = hash_hmac( 'md5', $scheme, $values['key'] );
    17851791        }
    17861792
    1787         $cached_salts[ $scheme ] = $key . $salt;
     1793        $cached_salts[ $scheme ] = $values['key'] . $values['salt'];
    17881794
    17891795        /** This filter is documented in wp-includes/pluggable.php */
    17901796        return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );