From fb109971e4e46a6970aad9acf8297b7387f9a70c Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 28 Oct 2015 01:11:57 +0000 Subject: [PATCH] Update Random_Compat to master. This update mostly concerns OpenSSL being unusable on PHP 5.3~5.3.3. See #28633, #34409 git-svn-id: https://develop.svn.wordpress.org/trunk@35410 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/random_compat/random.php | 36 +++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/wp-includes/random_compat/random.php b/src/wp-includes/random_compat/random.php index 1a4b326ed4..ebc7bd31cd 100644 --- a/src/wp-includes/random_compat/random.php +++ b/src/wp-includes/random_compat/random.php @@ -30,16 +30,16 @@ if (!defined('PHP_VERSION_ID')) { // This constant was introduced in PHP 5.2.7 $RandomCompatversion = explode('.', PHP_VERSION); define('PHP_VERSION_ID', ($RandomCompatversion[0] * 10000 + $RandomCompatversion[1] * 100 + $RandomCompatversion[2])); - unset($RandomCompatversion); + $RandomCompatversion = null; } if (PHP_VERSION_ID < 70000) { if (!defined('RANDOM_COMPAT_READ_BUFFER')) { define('RANDOM_COMPAT_READ_BUFFER', 8); } - $__DIR__ = dirname(__FILE__); - require_once $__DIR__.'/byte_safe_strings.php'; - require_once $__DIR__.'/cast_to_int.php'; - require_once $__DIR__.'/error_polyfill.php'; + $RandomCompatDIR = dirname(__FILE__); + require_once $RandomCompatDIR.'/byte_safe_strings.php'; + require_once $RandomCompatDIR.'/cast_to_int.php'; + require_once $RandomCompatDIR.'/error_polyfill.php'; if (!function_exists('random_bytes')) { /** * PHP 5.2.0 - 5.6.x way to implement random_bytes() @@ -58,7 +58,7 @@ if (PHP_VERSION_ID < 70000) { */ if (extension_loaded('libsodium')) { // See random_bytes_libsodium.php - require_once $__DIR__.'/random_bytes_libsodium.php'; + require_once $RandomCompatDIR.'/random_bytes_libsodium.php'; } if ( !function_exists('random_bytes') && @@ -75,7 +75,7 @@ if (PHP_VERSION_ID < 70000) { // that is not helpful to us here. // See random_bytes_dev_urandom.php - require_once $__DIR__.'/random_bytes_dev_urandom.php'; + require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php'; } if ( !function_exists('random_bytes') && @@ -83,7 +83,7 @@ if (PHP_VERSION_ID < 70000) { extension_loaded('mcrypt') ) { // See random_bytes_mcrypt.php - require_once $__DIR__.'/random_bytes_mcrypt.php'; + require_once $RandomCompatDIR.'/random_bytes_mcrypt.php'; } if ( !function_exists('random_bytes') && @@ -94,20 +94,28 @@ if (PHP_VERSION_ID < 70000) { $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); if (method_exists($RandomCompatCOMtest, 'GetRandom')) { // See random_bytes_com_dotnet.php - require_once $__DIR__.'/random_bytes_com_dotnet.php'; + require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php'; } } catch (com_exception $e) { // Don't try to use it. } - unset($RandomCompatCOMtest); + $RandomCompatCOMtest = null; } if ( !function_exists('random_bytes') && extension_loaded('openssl') && - PHP_VERSION_ID >= 50300 + ( + // Unix-like with PHP >= 5.3.0 or + ( + DIRECTORY_SEPARATOR === '/' && + PHP_VERSION_ID >= 50300 + ) || + // Windows with PHP >= 5.3.4 + PHP_VERSION_ID >= 50304 + ) ) { // See random_bytes_openssl.php - require_once $__DIR__.'/random_bytes_openssl.php'; + require_once $RandomCompatDIR.'/random_bytes_openssl.php'; } if (!function_exists('random_bytes')) { /** @@ -123,7 +131,7 @@ if (PHP_VERSION_ID < 70000) { } } if (!function_exists('random_int')) { - require_once $__DIR__.'/random_int.php'; + require_once $RandomCompatDIR.'/random_int.php'; } - unset($__DIR__); + $RandomCompatDIR = null; }