Avoid PHP Linting errors in the Random_Compat library under PHP7.

The latest updates to the library are larger than preferred, so instead this modifies the library to lint properly.

Fixes #42439 for 4.9

Built from https://develop.svn.wordpress.org/branches/4.9@42344


git-svn-id: http://core.svn.wordpress.org/branches/4.9@42173 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2017-12-01 03:07:42 +00:00
parent c4a15959f5
commit 1fdfabf74c
7 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
if ( ! is_callable( 'random_bytes' ) ):
/** /**
* Windows with PHP < 5.3.0 will not have the function * Windows with PHP < 5.3.0 will not have the function
* openssl_random_pseudo_bytes() available, so let's use * openssl_random_pseudo_bytes() available, so let's use
@ -79,3 +80,4 @@ function random_bytes($bytes)
'Could not gather sufficient random data' 'Could not gather sufficient random data'
); );
} }
endif;

View File

@ -30,6 +30,7 @@ if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
define('RANDOM_COMPAT_READ_BUFFER', 8); define('RANDOM_COMPAT_READ_BUFFER', 8);
} }
if ( ! is_callable( 'random_bytes' ) ):
/** /**
* Unless open_basedir is enabled, use /dev/urandom for * Unless open_basedir is enabled, use /dev/urandom for
* random numbers in accordance with best practices * random numbers in accordance with best practices
@ -146,3 +147,4 @@ function random_bytes($bytes)
'Error reading from source device' 'Error reading from source device'
); );
} }
endif;

View File

@ -26,6 +26,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
if ( ! is_callable( 'random_bytes' ) ):
/** /**
* If the libsodium PHP extension is loaded, we'll use it above any other * If the libsodium PHP extension is loaded, we'll use it above any other
* solution. * solution.
@ -84,3 +85,4 @@ function random_bytes($bytes)
'Could not gather sufficient random data' 'Could not gather sufficient random data'
); );
} }
endif;

View File

@ -26,6 +26,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
if ( ! is_callable( 'random_bytes' ) ):
/** /**
* If the libsodium PHP extension is loaded, we'll use it above any other * If the libsodium PHP extension is loaded, we'll use it above any other
* solution. * solution.
@ -84,3 +85,4 @@ function random_bytes($bytes)
'Could not gather sufficient random data' 'Could not gather sufficient random data'
); );
} }
endif;

View File

@ -27,6 +27,7 @@
*/ */
if ( ! is_callable( 'random_bytes' ) ):
/** /**
* Powered by ext/mcrypt (and thankfully NOT libmcrypt) * Powered by ext/mcrypt (and thankfully NOT libmcrypt)
* *
@ -74,3 +75,4 @@ function random_bytes($bytes)
'Could not gather sufficient random data' 'Could not gather sufficient random data'
); );
} }
endif;

View File

@ -26,6 +26,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
if ( ! is_callable( 'random_bytes' ) ):
/** /**
* Since openssl_random_pseudo_bytes() uses openssl's * Since openssl_random_pseudo_bytes() uses openssl's
* RAND_pseudo_bytes() API, which has been marked as deprecated by the * RAND_pseudo_bytes() API, which has been marked as deprecated by the
@ -81,3 +82,4 @@ function random_bytes($bytes)
'Could not gather sufficient random data' 'Could not gather sufficient random data'
); );
} }
endif;

View File

@ -26,6 +26,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
if ( ! is_callable( 'random_int' ) ):
/** /**
* Fetch a random integer between $min and $max inclusive * Fetch a random integer between $min and $max inclusive
* *
@ -189,3 +190,4 @@ function random_int($min, $max)
return (int) $val; return (int) $val;
} }
endif;