Commit 7ac4e139 authored by Côme Chilliet's avatar Côme Chilliet

Merge branch '6002-bump-php_min_version-to-php-7' into '1.4-dev'

Resolve "Bump PHP_MIN_VERSION to PHP 7"

See merge request fusiondirectory/fd!618
parents 111bfd92 9e1878c7
......@@ -1931,38 +1931,6 @@ function load_all_classes ()
}
}
if (!function_exists('random_int')) {
// PHP<7, we fallback on openssl_random_pseudo_bytes
function random_int ($min, $max)
{
$range = $max - $min;
if ($range <= 0) {
throw new Exception('Invalid range passed to random_int');
}
$log = log($range, 2);
// length in bytes
$nbBytes = (int) ($log / 8) + 1;
// length in bits
$nbBits = (int) $log + 1;
// set all lower bits to 1
$filter = pow(2, $nbBits) - 1;
if ($filter >= PHP_INT_MAX) {
$filter = PHP_INT_MAX;
}
do {
$randomBytes = openssl_random_pseudo_bytes($nbBytes, $strong);
if (!$strong || ($randomBytes === FALSE)) {
throw new Exception('Failed to get random bytes');
}
$rnd = hexdec(bin2hex($randomBytes));
// discard irrelevant bits
$rnd = $rnd & $filter;
} while ($rnd > $range);
return $min + $rnd;
}
}
function ldap_escape_f ($str, $ignore = '')
{
return ldap_escape($str, $ignore, LDAP_ESCAPE_FILTER);
......
......@@ -73,7 +73,7 @@ define("CONFIGRDN", "cn=config,ou=fusiondirectory,"); /*! Define FusionDirectory
/*!
* \brief Minimum PHP version
*/
define('PHP_MIN_VERSION', '5.6.0');
define('PHP_MIN_VERSION', '7.0.0');
/*!
* \brief Toggle crashing on PHP error, used for test suites
......
......@@ -95,14 +95,6 @@ class setupStepChecks extends setupStep
$M = TRUE;
$basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ];
/* Pseudo-random check */
$N = _('Checking cryptographically secure pseudo-random integers');
$D = _('You must use PHP>=7 or have openssl module activated so that FusionDirectory can generate cryptographically secure pseudo-random integers.');
$S = _('Please upgrade to PHP7 or activate openssl module.');
$R = (is_callable('random_int') || is_callable('openssl_random_pseudo_bytes'));
$M = TRUE;
$basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ];
/* Check for json support */
$N = msgPool::checkingFor('json');
$D = _('FusionDirectory requires this module to encode variables for javascript use.');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment