Ticket #19599: 19599.2.patch

File 19599.2.patch, 5.8 KB (added by SergeyBiryukov, 17 months ago)
  • wp-includes/default-constants.php

     
    140140 * @since 3.0.0 
    141141 */ 
    142142function wp_cookie_constants( ) { 
    143         global $wp_default_secret_key; 
    144  
    145143        /** 
    146144         * Used to guarantee unique hash cookies 
    147145         * @since 1.5 
     
    155153        } 
    156154 
    157155        /** 
    158          * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php 
    159          * @since 2.5.0 
    160          */ 
    161         $wp_default_secret_key = 'put your unique phrase here'; 
    162  
    163         /** 
    164156         * @since 2.0.0 
    165157         */ 
    166158        if ( !defined('USER_COOKIE') ) 
  • wp-includes/pluggable.php

     
    13131313 * @return string Salt value 
    13141314 */ 
    13151315function wp_salt($scheme = 'auth') { 
    1316         global $wp_default_secret_key; 
     1316        $secret_keys = array(); 
     1317 
     1318        if ( defined( 'SECRET_KEY' ) && ( '' != SECRET_KEY ) ) 
     1319                $secret_keys['secret_key'] = SECRET_KEY; 
     1320        if ( defined( 'AUTH_KEY' ) && ( '' != AUTH_KEY ) ) 
     1321                $secret_keys['auth_key'] = AUTH_KEY; 
     1322        if ( defined( 'SECURE_AUTH_KEY' ) && ( '' != SECURE_AUTH_KEY ) ) 
     1323                $secret_keys['secure_auth_key'] = SECURE_AUTH_KEY; 
     1324        if ( defined( 'LOGGED_IN_KEY' ) && ( '' != LOGGED_IN_KEY ) ) 
     1325                $secret_keys['logged_in_key'] = LOGGED_IN_KEY; 
     1326        if ( defined( 'NONCE_KEY' ) && ( '' != NONCE_KEY ) ) 
     1327                $secret_keys['nonce_key'] = NONCE_KEY; 
     1328        if ( defined( 'SECRET_SALT' ) && ( '' != SECRET_SALT ) ) 
     1329                $secret_keys['secret_salt'] = SECRET_SALT; 
     1330        if ( defined( 'AUTH_SALT' ) && ( '' != AUTH_SALT ) ) 
     1331                $secret_keys['auth_salt'] = AUTH_SALT; 
     1332        if ( defined( 'SECURE_AUTH_SALT' ) && ( '' != SECURE_AUTH_SALT ) ) 
     1333                $secret_keys['secure_auth_salt'] = SECURE_AUTH_SALT; 
     1334        if ( defined( 'LOGGED_IN_SALT' ) && ( '' != LOGGED_IN_SALT ) ) 
     1335                $secret_keys['logged_in_salt'] = LOGGED_IN_SALT; 
     1336        if ( defined( 'NONCE_SALT' ) && ( '' != NONCE_SALT ) ) 
     1337                $secret_keys['nonce_salt'] = NONCE_SALT; 
     1338 
     1339        $wp_default_secret_key = ''; 
     1340        if ( !empty( $secret_keys ) ) { 
     1341                $secret_keys_count = array_count_values( $secret_keys ); 
     1342                arsort( $secret_keys_count ); 
     1343                if ( array_shift( array_values( $secret_keys_count ) ) > 2 ) 
     1344                        $wp_default_secret_key = array_shift( array_keys( $secret_keys_count ) ); 
     1345        } 
     1346 
    13171347        $secret_key = ''; 
    1318         if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) ) 
    1319                 $secret_key = SECRET_KEY; 
     1348        if ( !empty( $secret_keys['secret_key'] ) && ( $wp_default_secret_key != $secret_keys['secret_key'] ) ) 
     1349                $secret_key = $secret_keys['secret_key']; 
    13201350 
    13211351        if ( 'auth' == $scheme ) { 
    1322                 if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) ) 
    1323                         $secret_key = AUTH_KEY; 
     1352                if ( !empty( $secret_keys['auth_key'] ) && ( $wp_default_secret_key != $secret_keys['auth_key'] ) ) 
     1353                        $secret_key = $secret_keys['auth_key']; 
    13241354 
    1325                 if ( defined('AUTH_SALT') && ('' != AUTH_SALT) && ( $wp_default_secret_key != AUTH_SALT) ) { 
    1326                         $salt = AUTH_SALT; 
    1327                 } elseif ( defined('SECRET_SALT') && ('' != SECRET_SALT) && ( $wp_default_secret_key != SECRET_SALT) ) { 
    1328                         $salt = SECRET_SALT; 
     1355                if ( !empty( $secret_keys['auth_salt'] ) && ( $wp_default_secret_key != $secret_keys['auth_salt'] ) ) { 
     1356                        $salt = $secret_keys['auth_salt']; 
     1357                } elseif ( !empty( $secret_keys['secret_salt'] ) && ( $wp_default_secret_key != $secret_keys['secret_salt'] ) ) { 
     1358                        $salt = $secret_keys['secret_salt']; 
    13291359                } else { 
    13301360                        $salt = get_site_option('auth_salt'); 
    13311361                        if ( empty($salt) ) { 
     
    13341364                        } 
    13351365                } 
    13361366        } elseif ( 'secure_auth' == $scheme ) { 
    1337                 if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) ) 
    1338                         $secret_key = SECURE_AUTH_KEY; 
     1367                if ( !empty( $secret_keys['secure_auth_key'] ) && ( $wp_default_secret_key != $secret_keys['secure_auth_key'] ) ) 
     1368                        $secret_key = $secret_keys['secure_auth_key']; 
    13391369 
    1340                 if ( defined('SECURE_AUTH_SALT') && ('' != SECURE_AUTH_SALT) && ( $wp_default_secret_key != SECURE_AUTH_SALT) ) { 
    1341                         $salt = SECURE_AUTH_SALT; 
     1370                if ( !empty( $secret_keys['secure_auth_salt'] ) && ( $wp_default_secret_key != $secret_keys['secure_auth_salt'] ) ) { 
     1371                        $salt = $secret_keys['secure_auth_salt']; 
    13421372                } else { 
    13431373                        $salt = get_site_option('secure_auth_salt'); 
    13441374                        if ( empty($salt) ) { 
     
    13471377                        } 
    13481378                } 
    13491379        } elseif ( 'logged_in' == $scheme ) { 
    1350                 if ( defined('LOGGED_IN_KEY') && ('' != LOGGED_IN_KEY) && ( $wp_default_secret_key != LOGGED_IN_KEY) ) 
    1351                         $secret_key = LOGGED_IN_KEY; 
     1380                if ( !empty( $secret_keys['logged_in_key'] ) && ( $wp_default_secret_key != $secret_keys['logged_in_key'] ) ) 
     1381                        $secret_key = $secret_keys['logged_in_key']; 
    13521382 
    1353                 if ( defined('LOGGED_IN_SALT') && ('' != LOGGED_IN_SALT) && ( $wp_default_secret_key != LOGGED_IN_SALT) ) { 
    1354                         $salt = LOGGED_IN_SALT; 
     1383                if ( !empty( $secret_keys['logged_in_salt'] ) && ( $wp_default_secret_key != $secret_keys['logged_in_salt'] ) ) { 
     1384                        $salt = $secret_keys['logged_in_salt']; 
    13551385                } else { 
    13561386                        $salt = get_site_option('logged_in_salt'); 
    13571387                        if ( empty($salt) ) { 
     
    13601390                        } 
    13611391                } 
    13621392        } elseif ( 'nonce' == $scheme ) { 
    1363                 if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) ) 
    1364                         $secret_key = NONCE_KEY; 
     1393                if ( !empty( $secret_keys['nonce_key'] ) && ( $wp_default_secret_key != $secret_keys['nonce_key'] ) ) 
     1394                        $secret_key = $secret_keys['nonce_key']; 
    13651395 
    1366                 if ( defined('NONCE_SALT') && ('' != NONCE_SALT) && ( $wp_default_secret_key != NONCE_SALT) ) { 
    1367                         $salt = NONCE_SALT; 
     1396                if ( !empty( $secret_keys['nonce_salt'] ) && ( $wp_default_secret_key != $secret_keys['nonce_salt'] ) ) { 
     1397                        $salt = $secret_keys['nonce_salt']; 
    13681398                } else { 
    13691399                        $salt = get_site_option('nonce_salt'); 
    13701400                        if ( empty($salt) ) {