Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -27,12 +27,9 @@ |
28 | 28 | $maintClass = false; |
29 | 29 | |
30 | 30 | // 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 " . |
33 | | - PHP_VERSION . ".\n\n" . |
34 | | - "If you are sure you already have PHP 5.2.3 or higher installed, it may be\n" . |
35 | | - "installed in a different path from PHP " . PHP_VERSION . ". Check with your system\n" . |
36 | | - "administrator.\n" ); |
| 31 | +if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.2.3' ) < 0 ) { |
| 32 | + require_once( dirname( __FILE__ ) . '/../includes/PHPVersionError.php' ); |
| 33 | + wfPHPVersionError( 'cli' ); |
37 | 34 | } |
38 | 35 | |
39 | 36 | // Wrapper for posix_isatty() |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1244,24 +1244,6 @@ |
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | /** |
1248 | | - * Print an error message and die, returning nonzero to the shell if any. Plain die() |
1249 | | - * fails to return nonzero to the shell if you pass a string. Entry points may customise |
1250 | | - * this function to return a prettier error message, but implementations must not assume |
1251 | | - * access to any of the usual MediaWiki infrastructure (AutoLoader, localisation, database, |
1252 | | - * etc). This should not be called directly once $wgFullyInitialised is set; instead, |
1253 | | - * throw an exception and let Exception.php handle whether or not it's possible to show |
1254 | | - * a prettier error. |
1255 | | - * |
1256 | | - * @param $msg String |
1257 | | - */ |
1258 | | -if( !function_exists( 'wfDie' ) ){ |
1259 | | - function wfDie( $msg = '' ) { |
1260 | | - echo $msg; |
1261 | | - die( 1 ); |
1262 | | - } |
1263 | | -} |
1264 | | - |
1265 | | -/** |
1266 | 1248 | * Throw a debugging exception. This function previously once exited the process, |
1267 | 1249 | * but now throws an exception instead, with similar results. |
1268 | 1250 | * |
Index: trunk/phase3/index.php |
— | — | @@ -40,25 +40,8 @@ |
41 | 41 | // has structures (try/catch, foo()->bar(), etc etc) which throw parse errors in PHP 4. |
42 | 42 | // Setup.php and ObjectCache.php have structures invalid in PHP 5.0 and 5.1, respectively. |
43 | 43 | if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ) { |
44 | | - $phpversion = htmlspecialchars( phpversion() ); |
45 | | - $errorMsg = <<<ENDL |
46 | | - <p> |
47 | | - MediaWiki requires PHP 5.2.3 or higher. You are running PHP $phpversion. |
48 | | - </p> |
49 | | - <p> |
50 | | - Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>. |
51 | | - PHP versions less than 5.3.0 are no longer supported by the PHP Group and will not receive |
52 | | - security or bugfix updates. |
53 | | - </p> |
54 | | - <p> |
55 | | - If for some reason you are unable to upgrade your PHP version, you will need to |
56 | | - <a href="http://www.mediawiki.org/wiki/Download">download</a> an older version |
57 | | - of MediaWiki from our website. See our |
58 | | - <a href="http://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a> |
59 | | - for details of which versions are compatible with prior versions of PHP. |
60 | | - </p> |
61 | | -ENDL; |
62 | | - wfDie( $errorMsg ); |
| 44 | + require( dirname( __FILE__ ) . '/includes/PHPVersionError.php' ); |
| 45 | + wfPHPVersionError( 'index.php' ); |
63 | 46 | } |
64 | 47 | |
65 | 48 | # Initialise common code. This gives us access to GlobalFunctions, the AutoLoader, and |
— | — | @@ -72,68 +55,3 @@ |
73 | 56 | |
74 | 57 | $mediaWiki = new MediaWiki(); |
75 | 58 | $mediaWiki->run(); |
76 | | - |
77 | | -/** |
78 | | - * Display something vaguely comprehensible in the event of a totally unrecoverable error. |
79 | | - * Does not assume access to *anything*; no globals, no autloader, no database, no localisation. |
80 | | - * Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php |
81 | | - * no longer need to be). |
82 | | - * |
83 | | - * Calling this function kills execution immediately. |
84 | | - * |
85 | | - * @param $errorMsg String fully-escaped HTML |
86 | | - */ |
87 | | -function wfDie( $errorMsg ){ |
88 | | - // Use the version set in DefaultSettings if possible, but don't rely on it |
89 | | - global $wgVersion, $wgLogo; |
90 | | - $version = isset( $wgVersion ) && $wgVersion |
91 | | - ? htmlspecialchars( $wgVersion ) |
92 | | - : ''; |
93 | | - |
94 | | - $script = $_SERVER['SCRIPT_NAME']; |
95 | | - $path = pathinfo( $script, PATHINFO_DIRNAME ) . '/'; |
96 | | - $path = str_replace( '//', '/', $path ); |
97 | | - |
98 | | - $logo = isset( $wgLogo ) && $wgLogo |
99 | | - ? $wgLogo |
100 | | - : $path . 'skins/common/images/mediawiki.png'; |
101 | | - $encLogo = htmlspecialchars( $logo ); |
102 | | - |
103 | | - header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 ); |
104 | | - header( 'Content-type: text/html; charset=UTF-8' ); |
105 | | - // Don't cache error pages! They cause no end of trouble... |
106 | | - header( 'Cache-control: none' ); |
107 | | - header( 'Pragma: nocache' ); |
108 | | - |
109 | | - ?> |
110 | | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
111 | | -<html xmlns='http://www.w3.org/1999/xhtml' lang='en'> |
112 | | - <head> |
113 | | - <title>MediaWiki <?php echo $version; ?></title> |
114 | | - <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> |
115 | | - <style type='text/css' media='screen'> |
116 | | - body { |
117 | | - color: #000; |
118 | | - background-color: #fff; |
119 | | - font-family: sans-serif; |
120 | | - padding: 2em; |
121 | | - text-align: center; |
122 | | - } |
123 | | - p, img, h1 { |
124 | | - text-align: left; |
125 | | - margin: 0.5em 0; |
126 | | - } |
127 | | - h1 { |
128 | | - font-size: 120%; |
129 | | - } |
130 | | - </style> |
131 | | - </head> |
132 | | - <body> |
133 | | - <img src="<?php echo $encLogo; ?>" alt='The MediaWiki logo' /> |
134 | | - <h1>MediaWiki <?php echo $version; ?> internal error</h1> |
135 | | - <div class='error'> <?php echo $errorMsg; ?> </div> |
136 | | - </body> |
137 | | -</html> |
138 | | - <?php |
139 | | - die( 1 ); |
140 | | -} |
Index: trunk/phase3/api.php |
— | — | @@ -37,19 +37,12 @@ |
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 | | -// We want a plain message on catastrophic errors that machines can identify |
42 | | -function wfDie( $msg = '' ) { |
43 | | - header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 ); |
44 | | - echo $msg; |
45 | | - die( 1 ); |
| 41 | +// Bail if PHP is too low |
| 42 | +if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ) { |
| 43 | + require( dirname( __FILE__ ) . '/includes/PHPVersionError.php' ); |
| 44 | + wfPHPVersionError( 'api.php' ); |
46 | 45 | } |
47 | 46 | |
48 | | -// 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 | | -} |
53 | | - |
54 | 47 | // Initialise common code. |
55 | 48 | if ( isset( $_SERVER['MW_COMPILED'] ) ) { |
56 | 49 | require ( 'phase3/includes/WebStart.php' ); |
— | — | @@ -67,9 +60,10 @@ |
68 | 61 | |
69 | 62 | // Verify that the API has not been disabled |
70 | 63 | if ( !$wgEnableAPI ) { |
71 | | - wfDie( 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php' |
72 | | - . '<pre><b>$wgEnableAPI=true;</b></pre>' |
73 | | - ); |
| 64 | + header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 ); |
| 65 | + echo( 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php' |
| 66 | + . '<pre><b>$wgEnableAPI=true;</b></pre>' ); |
| 67 | + die(1); |
74 | 68 | } |
75 | 69 | |
76 | 70 | // Selectively allow cross-site AJAX |
Index: trunk/phase3/load.php |
— | — | @@ -23,19 +23,12 @@ |
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | | -// We want error messages to not be interpreted as CSS or JS |
28 | | -function wfDie( $msg = '' ) { |
29 | | - header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 ); |
30 | | - echo "/* $msg */"; |
31 | | - die( 1 ); |
| 27 | +// Bail if PHP is too low |
| 28 | +if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ) { |
| 29 | + require( dirname( __FILE__ ) . '/includes/PHPVersionError.php' ); |
| 30 | + wfPHPVersionError( 'load.php' ); |
32 | 31 | } |
33 | 32 | |
34 | | -// 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 | | -} |
39 | | - |
40 | 33 | if ( isset( $_SERVER['MW_COMPILED'] ) ) { |
41 | 34 | require ( 'phase3/includes/WebStart.php' ); |
42 | 35 | } else { |