Centralise the minimum-required-php-version in a MW_MIN_PHP_VERSION constant in Defines.php. This requires loading Defines.php before the PHP4 version checks, so include a big note reminding people not to include anything other than vanilla define() statements in there.
I have a sneaking suspicion that including Defines.php in the entry points might not play nicely with HipHop, but I can't test it (wrong OS).
This commit is contained in:
parent
94e5186fb3
commit
7055add799
8 changed files with 56 additions and 25 deletions
10
api.php
10
api.php
|
|
@ -37,6 +37,9 @@
|
|||
// So extensions (and other code) can check whether they're running in API mode
|
||||
define( 'MW_API', true );
|
||||
|
||||
// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION
|
||||
require_once( dirname( __FILE__ ) . '/includes/Defines.php' );
|
||||
|
||||
// We want a plain message on catastrophic errors that machines can identify
|
||||
function wfDie( $msg = '' ) {
|
||||
header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 );
|
||||
|
|
@ -45,9 +48,10 @@ function wfDie( $msg = '' ) {
|
|||
}
|
||||
|
||||
// Die on unsupported PHP versions
|
||||
if( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ){
|
||||
$version = htmlspecialchars( $wgVersion );
|
||||
wfDie( "MediaWiki $version requires at least PHP version 5.2.3." );
|
||||
if( !function_exists( 'version_compare' ) || version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ){
|
||||
$version = htmlspecialchars( MW_VERSION );
|
||||
$phpversion = htmlspecialchars( MW_MIN_PHP_VERSION );
|
||||
wfDie( "MediaWiki $version requires at least PHP version $phpversion." );
|
||||
}
|
||||
|
||||
// Initialise common code.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* A few constants that might be needed during LocalSettings.php.
|
||||
* Global constants declarations. Do *NOT* include *anything* in this file which is
|
||||
* not a define() declaration; this file is included in all sorts of scopes and must
|
||||
* be parseable by PHP 4 without errors.
|
||||
*
|
||||
* Note: these constants must all be resolvable at compile time by HipHop,
|
||||
* since this file will not be executed during request startup for a compiled
|
||||
|
|
@ -15,6 +17,14 @@
|
|||
define( 'MW_VERSION', '1.19alpha' );
|
||||
define( 'MW_SPECIALPAGE_VERSION', 2 );
|
||||
|
||||
/**
|
||||
* Minimum version of PHP required to run; entry points will die
|
||||
* if they try to run on a version older than this
|
||||
*/
|
||||
define( 'MW_MIN_PHP_VERSION', '5.2.3' );
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**@{
|
||||
* Database related constants
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@
|
|||
abstract class Installer {
|
||||
|
||||
// This is the absolute minimum PHP version we can support
|
||||
const MINIMUM_PHP_VERSION = '5.2.3';
|
||||
// @deprecated since 1.18
|
||||
const MINIMUM_PHP_VERSION = MW_MIN_PHP_VERSION;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
|
|
@ -378,11 +379,11 @@ abstract class Installer {
|
|||
*/
|
||||
public function doEnvironmentChecks() {
|
||||
$phpVersion = phpversion();
|
||||
if( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) {
|
||||
if( version_compare( $phpVersion, MW_MIN_PHP_VERSION, '>=' ) ) {
|
||||
$this->showMessage( 'config-env-php', $phpVersion );
|
||||
$good = true;
|
||||
} else {
|
||||
$this->showMessage( 'config-env-php-toolow', $phpVersion, self::MINIMUM_PHP_VERSION );
|
||||
$this->showMessage( 'config-env-php-toolow', $phpVersion, MW_MIN_PHP_VERSION );
|
||||
$good = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
15
index.php
15
index.php
|
|
@ -36,14 +36,18 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
// Load global constants, including MW_VERSION and MW_MIN_PHP_VERSION
|
||||
require_once( dirname( __FILE__ ) . '/includes/Defines.php' );
|
||||
|
||||
// Bail on old versions of PHP. Pretty much every other file in the codebase
|
||||
// has structures (try/catch, foo()->bar(), etc etc) which throw parse errors in PHP 4.
|
||||
// Setup.php and ObjectCache.php have structures invalid in PHP 5.0 and 5.1, respectively.
|
||||
if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ) {
|
||||
if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ) {
|
||||
$phpversion = htmlspecialchars( phpversion() );
|
||||
$reqVersion = htmlspecialchars( MW_MIN_PHP_VERSION );
|
||||
$errorMsg = <<<ENDL
|
||||
<p>
|
||||
MediaWiki requires PHP 5.2.3 or higher. You are running PHP $phpversion.
|
||||
MediaWiki requires PHP $reqVersion or higher. You are running PHP $phpversion.
|
||||
</p>
|
||||
<p>
|
||||
Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>.
|
||||
|
|
@ -160,11 +164,8 @@ $mediaWiki->restInPeace();
|
|||
* @param $errorMsg String fully-escaped HTML
|
||||
*/
|
||||
function wfDie( $errorMsg ){
|
||||
// Use the version set in DefaultSettings if possible, but don't rely on it
|
||||
global $wgVersion, $wgLogo;
|
||||
$version = isset( $wgVersion ) && $wgVersion
|
||||
? htmlspecialchars( $wgVersion )
|
||||
: '';
|
||||
global $wgLogo;
|
||||
$version = htmlspecialchars( MW_VERSION );
|
||||
$logo = isset( $wgLogo ) && $wgLogo
|
||||
? $wgLogo
|
||||
: 'http://upload.wikimedia.org/wikipedia/commons/1/1c/MediaWiki_logo.png';
|
||||
|
|
|
|||
10
load.php
10
load.php
|
|
@ -30,10 +30,14 @@ function wfDie( $msg = '' ) {
|
|||
die( 1 );
|
||||
}
|
||||
|
||||
// Load global constants, including MW_VERSION and MW_MIN_PHP_VERSION
|
||||
require_once( dirname( __FILE__ ) . '/includes/Defines.php' );
|
||||
|
||||
// Die on unsupported PHP versions
|
||||
if( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ){
|
||||
$version = htmlspecialchars( $wgVersion );
|
||||
wfDie( "MediaWiki $version requires at least PHP version 5.2.3." );
|
||||
if( !function_exists( 'version_compare' ) || version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ){
|
||||
$version = htmlspecialchars( MW_VERSION );
|
||||
$phpversion = htmlspecialchars( MW_MIN_PHP_VERSION );
|
||||
wfDie( "MediaWiki $version requires at least PHP version $phpversion." );
|
||||
}
|
||||
|
||||
require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@
|
|||
* @defgroup Maintenance Maintenance
|
||||
*/
|
||||
|
||||
// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION
|
||||
require_once( dirname( __FILE__ ) . '/includes/Defines.php' );
|
||||
|
||||
// Define this so scripts can easily find doMaintenance.php
|
||||
define( 'RUN_MAINTENANCE_IF_MAIN', dirname( __FILE__ ) . '/doMaintenance.php' );
|
||||
define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless
|
||||
|
|
@ -27,10 +30,10 @@ define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless
|
|||
$maintClass = false;
|
||||
|
||||
// Make sure we're on PHP5 or better
|
||||
if ( version_compare( PHP_VERSION, '5.2.3' ) < 0 ) {
|
||||
die ( "Sorry! This version of MediaWiki requires PHP 5.2.3; you are running " .
|
||||
if ( version_compare( PHP_VERSION, MW_MIN_PHP_VERSION ) < 0 ) {
|
||||
die ( "Sorry! This version of MediaWiki requires PHP " . MW_MIN_PHP_VERSION . "; you are running " .
|
||||
PHP_VERSION . ".\n\n" .
|
||||
"If you are sure you already have PHP 5.2.3 or higher installed, it may be\n" .
|
||||
"If you are sure you already have PHP " . MW_MIN_PHP_VERSION . " or higher installed, it may be\n" .
|
||||
"installed in a different path from PHP " . PHP_VERSION . ". Check with your system\n" .
|
||||
"administrator.\n" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,13 @@
|
|||
* @see wfWaitForSlaves()
|
||||
*/
|
||||
|
||||
if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '5.2.3' ) < 0 ) ) {
|
||||
echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP 5.2.3 or higher. ABORTING.\n" .
|
||||
"Check if you have a newer php executable with a different name, such as php5.\n";
|
||||
// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION
|
||||
require_once( dirname( __FILE__ ) . '/includes/Defines.php' );
|
||||
|
||||
if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ) ) {
|
||||
echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP " .
|
||||
MW_MIN_PHP_VERSION . " or higher. ABORTING.\n" .
|
||||
"Check if you have a newer php executable with a different name, such as php5.\n";
|
||||
die( 1 );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,12 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '5.2.3' ) < 0 ) ) {
|
||||
echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP 5.2.3 or higher. ABORTING.\n" .
|
||||
// Include global constants, including MW_VERSION and MW_MIN_PHP_VERSION
|
||||
require_once( dirname( __FILE__ ) . '/includes/Defines.php' );
|
||||
|
||||
if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), MW_MIN_PHP_VERSION ) < 0 ) ) {
|
||||
echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP " .
|
||||
MW_MIN_PHP_VERSION . "or higher. ABORTING.\n" .
|
||||
"Check if you have a newer php executable with a different name, such as php5.\n";
|
||||
die( 1 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue