Make WordPress Core

Changeset 42119


Ignore:
Timestamp:
11/07/2017 12:29:26 AM (7 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

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

    r42056 r42119  
    19471947            $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
    19481948            // Old WP installs may not have AUTH_SALT defined.
    1949             $salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : rand();
     1949            $salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : (string) rand();
    19501950
    19511951            $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}';
Note: See TracChangeset for help on using the changeset viewer.