WPDB: Check that `AUTH_SALT` is not empty, Fix a PHP notice when `AUTH_SALT` is undefined.

Props jsonfry, mkomar, pento.
Merges [42119] and [42120] to the 4.6 branch.
Fixes #42431 and #42401 for 4.6.

Built from https://develop.svn.wordpress.org/branches/4.6@42232


git-svn-id: http://core.svn.wordpress.org/branches/4.6@42061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2017-11-27 01:09:36 +00:00
parent 98161af28f
commit 551d27db59
1 changed files with 1 additions and 1 deletions

View File

@ -1960,7 +1960,7 @@ class wpdb {
// If ext/hash is not present, compat.php's hash_hmac() does not support sha256. // If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
$algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
// Old WP installs may not have AUTH_SALT defined. // Old WP installs may not have AUTH_SALT defined.
$salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : rand(); $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand();
$placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}'; $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}';
} }