Internally cache return values of wp_salt(). Always run the filter. Big performance gains on a pageload that generates hundreds of nonces. see #19599.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20135 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-03-07 03:41:56 +00:00
parent 15d3cc2c9f
commit 20f416f286
1 changed files with 6 additions and 1 deletions

View File

@ -1310,6 +1310,10 @@ if ( !function_exists('wp_salt') ) :
function wp_salt( $scheme = 'auth' ) {
global $wp_secret_key_default; // This is set for localized builds for versions > 3.4.0.
static $cached_salts = array();
if ( isset( $cached_salts[ $scheme ] ) )
return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
static $duplicated_keys;
if ( null === $duplicated_keys ) {
$duplicated_keys = array( 'put your unique phrase here' => true );
@ -1355,7 +1359,8 @@ function wp_salt( $scheme = 'auth' ) {
$salt = hash_hmac( 'md5', $scheme, $key );
}
return apply_filters('salt', $key . $salt, $scheme);
$cached_salts[ $scheme ] = $key . $salt;
return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
}
endif;