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).
// 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 );
}
// 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.
<?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
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
*/
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
*/
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;
}
* @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>.
* @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';
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' );
* @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
$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" );
}
* @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 );
}
* @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 );
}