Index: trunk/phase3/maintenance/update.php |
— | — | @@ -25,8 +25,12 @@ |
26 | 26 | * @ingroup Maintenance |
27 | 27 | */ |
28 | 28 | |
29 | | -if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '5.2.3' ) < 0 ) ) { |
30 | | - echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP 5.2.3 or higher. ABORTING.\n" . |
| 29 | +// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION |
| 30 | +require_once( dirname( __FILE__ ) . '/includes/Defines.php' ); |
| 31 | + |
| 32 | +if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ) ) { |
| 33 | + echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP " . |
| 34 | + MW_MIN_PHP_VERSION . "or higher. ABORTING.\n" . |
31 | 35 | "Check if you have a newer php executable with a different name, such as php5.\n"; |
32 | 36 | die( 1 ); |
33 | 37 | } |
Index: trunk/phase3/maintenance/install.php |
— | — | @@ -20,9 +20,13 @@ |
21 | 21 | * @see wfWaitForSlaves() |
22 | 22 | */ |
23 | 23 | |
24 | | -if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '5.2.3' ) < 0 ) ) { |
25 | | - echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP 5.2.3 or higher. ABORTING.\n" . |
26 | | - "Check if you have a newer php executable with a different name, such as php5.\n"; |
| 24 | +// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION |
| 25 | +require_once( dirname( __FILE__ ) . '/includes/Defines.php' ); |
| 26 | + |
| 27 | +if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ) ) { |
| 28 | + echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP " . |
| 29 | + MW_MIN_PHP_VERSION . " or higher. ABORTING.\n" . |
| 30 | + "Check if you have a newer php executable with a different name, such as php5.\n"; |
27 | 31 | die( 1 ); |
28 | 32 | } |
29 | 33 | |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -20,6 +20,9 @@ |
21 | 21 | * @defgroup Maintenance Maintenance |
22 | 22 | */ |
23 | 23 | |
| 24 | +// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION |
| 25 | +require_once( dirname( __FILE__ ) . '/includes/Defines.php' ); |
| 26 | + |
24 | 27 | // Define this so scripts can easily find doMaintenance.php |
25 | 28 | define( 'RUN_MAINTENANCE_IF_MAIN', dirname( __FILE__ ) . '/doMaintenance.php' ); |
26 | 29 | define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless |
— | — | @@ -27,10 +30,10 @@ |
28 | 31 | $maintClass = false; |
29 | 32 | |
30 | 33 | // Make sure we're on PHP5 or better |
31 | | -if ( version_compare( PHP_VERSION, '5.2.3' ) < 0 ) { |
32 | | - die ( "Sorry! This version of MediaWiki requires PHP 5.2.3; you are running " . |
| 34 | +if ( version_compare( PHP_VERSION, MW_MIN_PHP_VERSION ) < 0 ) { |
| 35 | + die ( "Sorry! This version of MediaWiki requires PHP " . MW_MIN_PHP_VERSION . "; you are running " . |
33 | 36 | PHP_VERSION . ".\n\n" . |
34 | | - "If you are sure you already have PHP 5.2.3 or higher installed, it may be\n" . |
| 37 | + "If you are sure you already have PHP " . MW_MIN_PHP_VERSION . " or higher installed, it may be\n" . |
35 | 38 | "installed in a different path from PHP " . PHP_VERSION . ". Check with your system\n" . |
36 | 39 | "administrator.\n" ); |
37 | 40 | } |
Index: trunk/phase3/includes/Defines.php |
— | — | @@ -1,6 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * A few constants that might be needed during LocalSettings.php. |
| 4 | + * Global constants declarations. Do *NOT* include *anything* in this file which is |
| 5 | + * not a define() declaration; this file is included in all sorts of scopes and must |
| 6 | + * be parseable by PHP 4 without errors. |
5 | 7 | * |
6 | 8 | * Note: these constants must all be resolvable at compile time by HipHop, |
7 | 9 | * since this file will not be executed during request startup for a compiled |
— | — | @@ -15,6 +17,14 @@ |
16 | 18 | define( 'MW_VERSION', '1.19alpha' ); |
17 | 19 | define( 'MW_SPECIALPAGE_VERSION', 2 ); |
18 | 20 | |
| 21 | +/** |
| 22 | + * Minimum version of PHP required to run; entry points will die |
| 23 | + * if they try to run on a version older than this |
| 24 | + */ |
| 25 | +define( 'MW_MIN_PHP_VERSION', '5.2.3' ); |
| 26 | + |
| 27 | +/**@}*/ |
| 28 | + |
19 | 29 | /**@{ |
20 | 30 | * Database related constants |
21 | 31 | */ |
Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -24,7 +24,8 @@ |
25 | 25 | abstract class Installer { |
26 | 26 | |
27 | 27 | // This is the absolute minimum PHP version we can support |
28 | | - const MINIMUM_PHP_VERSION = '5.2.3'; |
| 28 | + // @deprecated since 1.18 |
| 29 | + const MINIMUM_PHP_VERSION = MW_MIN_PHP_VERSION; |
29 | 30 | |
30 | 31 | /** |
31 | 32 | * @var array |
— | — | @@ -378,11 +379,11 @@ |
379 | 380 | */ |
380 | 381 | public function doEnvironmentChecks() { |
381 | 382 | $phpVersion = phpversion(); |
382 | | - if( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) { |
| 383 | + if( version_compare( $phpVersion, MW_MIN_PHP_VERSION, '>=' ) ) { |
383 | 384 | $this->showMessage( 'config-env-php', $phpVersion ); |
384 | 385 | $good = true; |
385 | 386 | } else { |
386 | | - $this->showMessage( 'config-env-php-toolow', $phpVersion, self::MINIMUM_PHP_VERSION ); |
| 387 | + $this->showMessage( 'config-env-php-toolow', $phpVersion, MW_MIN_PHP_VERSION ); |
387 | 388 | $good = false; |
388 | 389 | } |
389 | 390 | |
Index: trunk/phase3/index.php |
— | — | @@ -36,14 +36,18 @@ |
37 | 37 | * @file |
38 | 38 | */ |
39 | 39 | |
| 40 | +// Load global constants, including MW_VERSION and MW_MIN_PHP_VERSION |
| 41 | +require_once( dirname( __FILE__ ) . '/includes/Defines.php' ); |
| 42 | + |
40 | 43 | // Bail on old versions of PHP. Pretty much every other file in the codebase |
41 | 44 | // has structures (try/catch, foo()->bar(), etc etc) which throw parse errors in PHP 4. |
42 | 45 | // Setup.php and ObjectCache.php have structures invalid in PHP 5.0 and 5.1, respectively. |
43 | | -if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ) { |
| 46 | +if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ) { |
44 | 47 | $phpversion = htmlspecialchars( phpversion() ); |
| 48 | + $reqVersion = htmlspecialchars( MW_MIN_PHP_VERSION ); |
45 | 49 | $errorMsg = <<<ENDL |
46 | 50 | <p> |
47 | | - MediaWiki requires PHP 5.2.3 or higher. You are running PHP $phpversion. |
| 51 | + MediaWiki requires PHP $reqVersion or higher. You are running PHP $phpversion. |
48 | 52 | </p> |
49 | 53 | <p> |
50 | 54 | Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>. |
— | — | @@ -160,11 +164,8 @@ |
161 | 165 | * @param $errorMsg String fully-escaped HTML |
162 | 166 | */ |
163 | 167 | function wfDie( $errorMsg ){ |
164 | | - // Use the version set in DefaultSettings if possible, but don't rely on it |
165 | | - global $wgVersion, $wgLogo; |
166 | | - $version = isset( $wgVersion ) && $wgVersion |
167 | | - ? htmlspecialchars( $wgVersion ) |
168 | | - : ''; |
| 168 | + global $wgLogo; |
| 169 | + $version = htmlspecialchars( MW_VERSION ); |
169 | 170 | $logo = isset( $wgLogo ) && $wgLogo |
170 | 171 | ? $wgLogo |
171 | 172 | : 'http://upload.wikimedia.org/wikipedia/commons/1/1c/MediaWiki_logo.png'; |
Index: trunk/phase3/api.php |
— | — | @@ -37,6 +37,9 @@ |
38 | 38 | // So extensions (and other code) can check whether they're running in API mode |
39 | 39 | define( 'MW_API', true ); |
40 | 40 | |
| 41 | +// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION |
| 42 | +require_once( dirname( __FILE__ ) . '/includes/Defines.php' ); |
| 43 | + |
41 | 44 | // We want a plain message on catastrophic errors that machines can identify |
42 | 45 | function wfDie( $msg = '' ) { |
43 | 46 | header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 ); |
— | — | @@ -45,9 +48,10 @@ |
46 | 49 | } |
47 | 50 | |
48 | 51 | // Die on unsupported PHP versions |
49 | | -if( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ){ |
50 | | - $version = htmlspecialchars( $wgVersion ); |
51 | | - wfDie( "MediaWiki $version requires at least PHP version 5.2.3." ); |
| 52 | +if( !function_exists( 'version_compare' ) || version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ){ |
| 53 | + $version = htmlspecialchars( MW_VERSION ); |
| 54 | + $phpversion = htmlspecialchars( MW_MIN_PHP_VERSION ); |
| 55 | + wfDie( "MediaWiki $version requires at least PHP version $phpversion." ); |
52 | 56 | } |
53 | 57 | |
54 | 58 | // Initialise common code. |
Index: trunk/phase3/load.php |
— | — | @@ -30,10 +30,14 @@ |
31 | 31 | die( 1 ); |
32 | 32 | } |
33 | 33 | |
| 34 | +// Load global constants, including MW_VERSION and MW_MIN_PHP_VERSION |
| 35 | +require_once( dirname( __FILE__ ) . '/includes/Defines.php' ); |
| 36 | + |
34 | 37 | // Die on unsupported PHP versions |
35 | | -if( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ){ |
36 | | - $version = htmlspecialchars( $wgVersion ); |
37 | | - wfDie( "MediaWiki $version requires at least PHP version 5.2.3." ); |
| 38 | +if( !function_exists( 'version_compare' ) || version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ){ |
| 39 | + $version = htmlspecialchars( MW_VERSION ); |
| 40 | + $phpversion = htmlspecialchars( MW_MIN_PHP_VERSION ); |
| 41 | + wfDie( "MediaWiki $version requires at least PHP version $phpversion." ); |
38 | 42 | } |
39 | 43 | |
40 | 44 | require ( dirname( __FILE__ ) . '/includes/WebStart.php' ); |