WordPress.org

Make WordPress Core

Ticket #42431: auth-salt-fallback.diff

File auth-salt-fallback.diff, 600 bytes (added by jsonfry, 2 years ago)

patch for the 4.8 branch

  • wp-includes/wp-db.php

    diff --git wp-includes/wp-db.php wp-includes/wp-db.php
    index 553cd39d9f..bd488258ba 100644
    class wpdb { 
    19641964                        // If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
    19651965                        $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
    19661966                        // Old WP installs may not have AUTH_SALT defined.
    1967                         $salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : rand();
     1967                        $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : strval(rand());
    19681968
    19691969                        $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}';
    19701970                }