Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove php_version_at_least() API function
Standard version_compare() function was introduced in PHP 4.1, and
should be used instead.

Fixes #22842
  • Loading branch information
dregad committed Oct 22, 2017
1 parent bc40253 commit e78e718
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 36 deletions.
6 changes: 4 additions & 2 deletions core.php
Expand Up @@ -197,9 +197,11 @@ function __autoload( $p_class ) {
require_api( 'php_api.php' );

# Enforce our minimum PHP requirements
if( !php_version_at_least( PHP_MIN_VERSION ) ) {
if( version_compare( PHP_VERSION, PHP_MIN_VERSION, '<' ) ) {
@ob_end_clean();
echo '<strong>FATAL ERROR: Your version of PHP is too old. MantisBT requires PHP version ' . PHP_MIN_VERSION . ' or newer</strong><br />Your version of PHP is version ' . phpversion();
echo '<strong>FATAL ERROR: Your version of PHP is too old. '
. 'MantisBT requires ' . PHP_MIN_VERSION . ' or newer</strong><br />'
. 'Your are running PHP version <em>' . PHP_VERSION . '</em>';
die();
}

Expand Down
34 changes: 0 additions & 34 deletions core/php_api.php
Expand Up @@ -53,40 +53,6 @@ function php_mode() {
return $s_mode;
}

/**
* Returns true if the current PHP version is higher than the one
* specified in the given string
* @param string $p_version_string Version string to compare.
* @return boolean
*/
function php_version_at_least( $p_version_string ) {
static $s_cached_version;

if( isset( $s_cached_version[$p_version_string] ) ) {
return $s_cached_version[$p_version_string];
}

$t_curver = array_pad( explode( '.', phpversion() ), 3, 0 );
$t_minver = array_pad( explode( '.', $p_version_string ), 3, 0 );

for( $i = 0;$i < 3;$i = $i + 1 ) {
$t_cur = (int)$t_curver[$i];
$t_min = (int)$t_minver[$i];

if( $t_cur < $t_min ) {
$s_cached_version[$p_version_string] = false;
return false;
} else if( $t_cur > $t_min ) {
$s_cached_version[$p_version_string] = true;
return true;
}
}

# if we get here, the versions must match exactly so:
$s_cached_version[$p_version_string] = true;
return true;
}

# If mb_* not defined, define it to map to standard methods.
if( !function_exists( 'mb_substr' ) ) {
/**
Expand Down

0 comments on commit e78e718

Please sign in to comment.