Make WordPress Core


Ignore:
Timestamp:
06/11/2014 06:35:42 PM (12 years ago)
Author:
wonderboymusic
Message:

Don't use variable variables in wp_salt().

See #27881.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r28628 r28741  
    17741774                foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) {
    17751775                        foreach ( array( 'KEY', 'SALT' ) as $second ) {
    1776                                 if ( ! defined( "{$first}_{$second}" ) )
     1776                                if ( ! defined( "{$first}_{$second}" ) ) {
    17771777                                        continue;
     1778                                }
    17781779                                $value = constant( "{$first}_{$second}" );
    17791780                                $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] );
     
    17821783        }
    17831784
    1784         $key = $salt = '';
    1785         if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) )
    1786                 $key = SECRET_KEY;
    1787         if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) )
    1788                 $salt = SECRET_SALT;
     1785        $values = array(
     1786                'key' => '',
     1787                'salt' => ''
     1788        );
     1789        if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) {
     1790                $values['key'] = SECRET_KEY;
     1791        }
     1792        if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) {
     1793                $values['salt'] = SECRET_SALT;
     1794        }
    17891795
    17901796        if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) {
     
    17921798                        $const = strtoupper( "{$scheme}_{$type}" );
    17931799                        if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) {
    1794                                 $$type = constant( $const );
    1795                         } elseif ( ! $$type ) {
    1796                                 $$type = get_site_option( "{$scheme}_{$type}" );
    1797                                 if ( ! $$type ) {
    1798                                         $$type = wp_generate_password( 64, true, true );
    1799                                         update_site_option( "{$scheme}_{$type}", $$type );
     1800                                $values[ $type ] = constant( $const );
     1801                        } elseif ( ! $values[ $type ] ) {
     1802                                $values[ $type ] = get_site_option( "{$scheme}_{$type}" );
     1803                                if ( ! $values[ $type ] ) {
     1804                                        $values[ $type ] = wp_generate_password( 64, true, true );
     1805                                        update_site_option( "{$scheme}_{$type}", $values[ $type ] );
    18001806                                }
    18011807                        }
    18021808                }
    18031809        } else {
    1804                 if ( ! $key ) {
    1805                         $key = get_site_option( 'secret_key' );
    1806                         if ( ! $key ) {
    1807                                 $key = wp_generate_password( 64, true, true );
    1808                                 update_site_option( 'secret_key', $key );
     1810                if ( ! $values['key'] ) {
     1811                        $values['key'] = get_site_option( 'secret_key' );
     1812                        if ( ! $values['key'] ) {
     1813                                $values['key'] = wp_generate_password( 64, true, true );
     1814                                update_site_option( 'secret_key', $values['key'] );
    18091815                        }
    18101816                }
    1811                 $salt = hash_hmac( 'md5', $scheme, $key );
    1812         }
    1813 
    1814         $cached_salts[ $scheme ] = $key . $salt;
     1817                $values['salt'] = hash_hmac( 'md5', $scheme, $values['key'] );
     1818        }
     1819
     1820        $cached_salts[ $scheme ] = $values['key'] . $values['salt'];
    18151821
    18161822        /** This filter is documented in wp-includes/pluggable.php */
Note: See TracChangeset for help on using the changeset viewer.