Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3854c4d

Browse files
committedApr 5, 2013
use the in-built version_compare functionality to check php version is valid.
1 parent c53a134 commit 3854c4d

File tree

2 files changed

+1
-35
lines changed

2 files changed

+1
-35
lines changed
 

‎core.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ function __autoload( $p_class ) {
280280
require_api( 'php_api.php' );
281281

282282
# Enforce our minimum PHP requirements
283-
if( !php_version_at_least( PHP_MIN_VERSION ) ) {
283+
if( !(version_compare(PHP_VERSION, PHP_MIN_VERSION ) >= 0 ) ) {
284284
@ob_end_clean();
285285
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();
286286
die();

‎core/php_api.php

-34
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,3 @@ function php_mode() {
5252

5353
return $s_mode;
5454
}
55-
56-
/**
57-
* Returns true if the current PHP version is higher than the one specified in the given string
58-
* @param string $p_version_string php version string to check
59-
* @return bool
60-
*/
61-
function php_version_at_least( $p_version_string ) {
62-
static $s_cached_version;
63-
64-
if( isset( $s_cached_version[$p_version_string] ) ) {
65-
return $s_cached_version[$p_version_string];
66-
}
67-
68-
$t_curver = array_pad( explode( '.', phpversion() ), 3, 0 );
69-
$t_minver = array_pad( explode( '.', $p_version_string ), 3, 0 );
70-
71-
for( $i = 0;$i < 3;$i = $i + 1 ) {
72-
$t_cur = (int) $t_curver[$i];
73-
$t_min = (int) $t_minver[$i];
74-
75-
if( $t_cur < $t_min ) {
76-
$s_cached_version[$p_version_string] = false;
77-
return false;
78-
}
79-
else if( $t_cur > $t_min ) {
80-
$s_cached_version[$p_version_string] = true;
81-
return true;
82-
}
83-
}
84-
85-
# if we get here, the versions must match exactly so:
86-
$s_cached_version[$p_version_string] = true;
87-
return true;
88-
}

0 commit comments

Comments
 (0)
Please sign in to comment.