Ticket #28633: 28633.diff
File 28633.diff, 2.5 KB (added by , 10 years ago) |
---|
-
src/wp-includes/pluggable.php
if ( !function_exists('wp_rand') ) : 2131 2131 /** 2132 2132 * Generates a random number 2133 2133 * 2134 2134 * @since 2.6.2 2135 2135 * 2136 2136 * @global string $rnd_value 2137 2137 * @staticvar string $seed 2138 2138 * 2139 2139 * @param int $min Lower limit for the generated number 2140 2140 * @param int $max Upper limit for the generated number 2141 2141 * @return int A random number between min and max 2142 2142 */ 2143 2143 function wp_rand( $min = 0, $max = 0 ) { 2144 2144 global $rnd_value; 2145 2145 2146 // We're only dealing with int's 2147 $min = (int) $min; 2148 $max = (int) $max; 2149 2150 // Use an external source? 2151 static $external_rand_source_available = true; 2152 if ( $external_rand_source_available ) { 2153 try { 2154 $val = random_int( min( $min, $max ), max( $min, $max ) ); 2155 if ( false !== $val ) { 2156 return abs( $val ); 2157 } else { 2158 $external_rand_source_available = false; 2159 } 2160 } catch ( Throwable $t ) { 2161 $external_rand_source_available = false; 2162 } catch ( Exception $e ) { 2163 $external_rand_source_available = false; 2164 } 2165 } 2166 2146 2167 // Reset $rnd_value after 14 uses 2147 2168 // 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value 2148 2169 if ( strlen($rnd_value) < 8 ) { 2149 2170 if ( defined( 'WP_SETUP_CONFIG' ) ) 2150 2171 static $seed = ''; 2151 2172 else 2152 2173 $seed = get_transient('random_seed'); 2153 2174 $rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed ); 2154 2175 $rnd_value .= sha1($rnd_value); 2155 2176 $rnd_value .= sha1($rnd_value . $seed); 2156 2177 $seed = md5($seed . $rnd_value); 2157 2178 if ( ! defined( 'WP_SETUP_CONFIG' ) && ! defined( 'WP_INSTALLING' ) ) { 2158 2179 set_transient( 'random_seed', $seed ); 2159 2180 } 2160 2181 } -
src/wp-includes/compat.php
function hash_equals( $a, $b ) { 248 248 249 249 // Do not attempt to "optimize" this. 250 250 for ( $i = 0; $i < $a_length; $i++ ) { 251 251 $result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] ); 252 252 } 253 253 254 254 return $result === 0; 255 255 } 256 256 endif; 257 257 258 258 // JSON_PRETTY_PRINT was introduced in PHP 5.4 259 259 // Defined here to prevent a notice when using it with wp_json_encode() 260 260 if ( ! defined( 'JSON_PRETTY_PRINT' ) ) { 261 261 define( 'JSON_PRETTY_PRINT', 128 ); 262 262 } 263 264 if ( ! function_exists( 'random_int' ) ) { 265 include ABSPATH . WPINC . '/random_compat/random.php'; 266 } 267 No newline at end of file