From f7fbbcba0d230c4bf72c86e7c0f0aca5069acccd Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 7 Nov 2017 00:29:26 +0000 Subject: [PATCH] WPDB: Fix a PHP notice when `AUTH_SALT` is undefined. In `wpdb::placeholder_escape()`, the key for `hash_hmac()` falls back to `rand()` when `AUTH_SALT` is undefined. `hash_hmac()` requires the key to be a string, however, so we need to cast it as such. Props mkomar. Fixes #42401. git-svn-id: https://develop.svn.wordpress.org/trunk@42119 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/wp-db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index e7ec314e7b..04792d4db4 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -1946,7 +1946,7 @@ class wpdb { // If ext/hash is not present, compat.php's hash_hmac() does not support sha256. $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; // Old WP installs may not have AUTH_SALT defined. - $salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : rand(); + $salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : (string) rand(); $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}'; }