Index: trunk/phase3/php5.php5 |
— | — | @@ -1,9 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Test for *.php5 capability in webserver |
6 | | - * Used by includes/templates/PHP4.php |
7 | | - */ |
8 | | -if ( version_compare( phpversion(), '5.1.0' ) >= 0 ) { |
9 | | - echo 'y'.'e'.'s'; |
10 | | -} |
Index: trunk/phase3/index.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * This is the main web entry point for MediaWiki. |
6 | 5 | * |
— | — | @@ -37,6 +36,31 @@ |
38 | 37 | * @file |
39 | 38 | */ |
40 | 39 | |
| 40 | +// Bail on old versions of PHP. Pretty much every other file in the codebase |
| 41 | +// has structures (try/catch, foo()->bar(), etc etc) which throw parse errors in PHP 4. |
| 42 | +// 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.0' ) < 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 ); |
| 63 | +} |
| 64 | + |
41 | 65 | # Initialise common code. This gives us access to GlobalFunctions, the AutoLoader, and |
42 | 66 | # the globals $wgRequest, $wgOut, $wgUser, $wgLang and $wgContLang, amongst others; it |
43 | 67 | # does *not* load $wgTitle or $wgArticle |
— | — | @@ -47,7 +71,8 @@ |
48 | 72 | |
49 | 73 | $maxLag = $wgRequest->getVal( 'maxlag' ); |
50 | 74 | if ( !is_null( $maxLag ) ) { |
51 | | - list( $host, $lag ) = wfGetLB()->getMaxLag(); |
| 75 | + $lb = wfGetLB(); // foo()->bar() is not supported in PHP4 |
| 76 | + list( $host, $lag ) = $lb->getMaxLag(); |
52 | 77 | if ( $lag > $maxLag ) { |
53 | 78 | header( 'HTTP/1.1 503 Service Unavailable' ); |
54 | 79 | header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); |
— | — | @@ -123,3 +148,58 @@ |
124 | 149 | wfProfileOut( 'index.php' ); |
125 | 150 | |
126 | 151 | $mediaWiki->restInPeace(); |
| 152 | + |
| 153 | +/** |
| 154 | + * Display something vaguely comprehensible in the event of a totally unrecoverable error. |
| 155 | + * Does not assume access to *anything*; no globals, no autloader, no database, no localisation. |
| 156 | + * Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php |
| 157 | + * no longer need to be). |
| 158 | + * |
| 159 | + * Calling this function kills execution immediately. |
| 160 | + * |
| 161 | + * @param $errorMsg String fully-escaped HTML |
| 162 | + */ |
| 163 | +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 | + : ''; |
| 169 | + $logo = isset( $wgLogo ) && $wgLogo |
| 170 | + ? $wgLogo |
| 171 | + : 'http://upload.wikimedia.org/wikipedia/commons/1/1c/MediaWiki_logo.png'; |
| 172 | + |
| 173 | + header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 ); |
| 174 | + |
| 175 | + ?> |
| 176 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 177 | +<html xmlns='http://www.w3.org/1999/xhtml' lang='en'> |
| 178 | + <head> |
| 179 | + <title>MediaWiki <?php echo $version; ?></title> |
| 180 | + <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> |
| 181 | + <style type='text/css' media='screen'> |
| 182 | + body { |
| 183 | + color: #000; |
| 184 | + background-color: #fff; |
| 185 | + font-family: sans-serif; |
| 186 | + padding: 2em; |
| 187 | + text-align: center; |
| 188 | + } |
| 189 | + p, img, h1 { |
| 190 | + text-align: left; |
| 191 | + margin: 0.5em 0; |
| 192 | + } |
| 193 | + h1 { |
| 194 | + font-size: 120%; |
| 195 | + } |
| 196 | + </style> |
| 197 | + </head> |
| 198 | + <body> |
| 199 | + <img src="<?php echo $logo; ?>" alt='The MediaWiki logo' /> |
| 200 | + <h1>MediaWiki <?php echo $version; ?> internal error</h1> |
| 201 | + <div class='error'> <?php echo $errorMsg; ?> </div> |
| 202 | + </body> |
| 203 | +</html> |
| 204 | + <?php |
| 205 | + die( 1 ); |
| 206 | +} |
\ No newline at end of file |
Index: trunk/phase3/api.php |
— | — | @@ -37,7 +37,20 @@ |
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 | | -// Initialise common code |
| 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 ); |
| 46 | +} |
| 47 | + |
| 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 | +// Initialise common code. |
42 | 55 | require ( dirname( __FILE__ ) . '/includes/WebStart.php' ); |
43 | 56 | |
44 | 57 | wfProfileIn( 'api.php' ); |
— | — | @@ -61,9 +74,9 @@ |
62 | 75 | |
63 | 76 | // Verify that the API has not been disabled |
64 | 77 | if ( !$wgEnableAPI ) { |
65 | | - echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php'; |
66 | | - echo '<pre><b>$wgEnableAPI=true;</b></pre>'; |
67 | | - die( 1 ); |
| 78 | + wfDie( 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php' |
| 79 | + . '<pre><b>$wgEnableAPI=true;</b></pre>' |
| 80 | + ); |
68 | 81 | } |
69 | 82 | |
70 | 83 | // Selectively allow cross-site AJAX |
— | — | @@ -131,7 +144,8 @@ |
132 | 145 | $_SERVER['HTTP_USER_AGENT'] |
133 | 146 | ); |
134 | 147 | $items[] = $wgRequest->wasPosted() ? 'POST' : 'GET'; |
135 | | - if ( $processor->getModule()->mustBePosted() ) { |
| 148 | + $module = $processor->getModule(); |
| 149 | + if ( $module->mustBePosted() ) { |
136 | 150 | $items[] = "action=" . $wgRequest->getVal( 'action' ); |
137 | 151 | } else { |
138 | 152 | $items[] = wfArrayToCGI( $wgRequest->getValues() ); |
— | — | @@ -140,6 +154,8 @@ |
141 | 155 | wfDebug( "Logged API request to $wgAPIRequestLog\n" ); |
142 | 156 | } |
143 | 157 | |
144 | | -// Shut down the database |
145 | | -wfGetLBFactory()->shutdown(); |
| 158 | +// Shut down the database. foo()->bar() syntax is not supported in PHP4: we won't ever actually |
| 159 | +// get here to worry about whether this should be = or =&, but the file has to parse properly. |
| 160 | +$lb = wfGetLBFactory(); |
| 161 | +$lb->shutdown(); |
146 | 162 | |
Index: trunk/phase3/load.php |
— | — | @@ -23,6 +23,19 @@ |
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 ); |
| 32 | +} |
| 33 | + |
| 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 | + |
27 | 40 | require ( dirname( __FILE__ ) . '/includes/WebStart.php' ); |
28 | 41 | wfProfileIn( 'load.php' ); |
29 | 42 | |
— | — | @@ -48,5 +61,7 @@ |
49 | 62 | wfProfileOut( 'load.php' ); |
50 | 63 | wfLogProfilingData(); |
51 | 64 | |
52 | | -// Shut down the database |
53 | | -wfGetLBFactory()->shutdown(); |
| 65 | +// Shut down the database. foo()->bar() syntax is not supported in PHP4, and this file |
| 66 | +// needs to *parse* in PHP4, although we'll never get down here to worry about = vs =& |
| 67 | +$lb = wfGetLBFactory(); |
| 68 | +$lb->shutdown(); |
Index: trunk/phase3/includes/templates/NoLocalSettings.php |
— | — | @@ -1,64 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Template used when there is no LocalSettings.php file |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup Templates |
8 | | - */ |
9 | | - |
10 | | -if ( !isset( $wgVersion ) ) { |
11 | | - $wgVersion = 'VERSION'; |
12 | | -} |
13 | | -$script = $_SERVER['SCRIPT_NAME']; |
14 | | -$path = pathinfo( $script, PATHINFO_DIRNAME ) . '/'; |
15 | | -$path = str_replace( '//', '/', $path ); |
16 | | -$ext = pathinfo( $script, PATHINFO_EXTENSION ); |
17 | | - |
18 | | -# Check to see if the installer is running |
19 | | -if ( !function_exists( 'session_name' ) ) { |
20 | | - $installerStarted = false; |
21 | | -} else { |
22 | | - session_name( 'mw_installer_session' ); |
23 | | - $oldReporting = error_reporting( E_ALL & ~E_NOTICE ); |
24 | | - $success = session_start(); |
25 | | - error_reporting( $oldReporting ); |
26 | | - $installerStarted = ( $success && isset( $_SESSION['installData'] ) ); |
27 | | -} |
28 | | -?> |
29 | | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
30 | | -<html xmlns='http://www.w3.org/1999/xhtml' lang='en'> |
31 | | - <head> |
32 | | - <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ) ?></title> |
33 | | - <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> |
34 | | - <style type='text/css' media='screen'> |
35 | | - html, body { |
36 | | - color: #000; |
37 | | - background-color: #fff; |
38 | | - font-family: sans-serif; |
39 | | - text-align: center; |
40 | | - } |
41 | | - |
42 | | - h1 { |
43 | | - font-size: 150%; |
44 | | - } |
45 | | - </style> |
46 | | - </head> |
47 | | - <body> |
48 | | - <img src="<?php echo htmlspecialchars( $path ) ?>skins/common/images/mediawiki.png" alt='The MediaWiki logo' /> |
49 | | - |
50 | | - <h1>MediaWiki <?php echo htmlspecialchars( $wgVersion ) ?></h1> |
51 | | - <div class='error'> |
52 | | - <p>LocalSettings.php not found.</p> |
53 | | - <p> |
54 | | - <?php |
55 | | - if ( $installerStarted ) { |
56 | | - echo( "Please <a href=\"" . htmlspecialchars( $path ) . "mw-config/index." . htmlspecialchars( $ext ) . "\"> complete the installation</a> and download LocalSettings.php." ); |
57 | | - } else { |
58 | | - echo( "Please <a href=\"" . htmlspecialchars( $path ) . "mw-config/index." . htmlspecialchars( $ext ) . "\"> set up the wiki</a> first." ); |
59 | | - } |
60 | | - ?> |
61 | | - </p> |
62 | | - |
63 | | - </div> |
64 | | - </body> |
65 | | -</html> |
Index: trunk/phase3/includes/templates/PHP4.php |
— | — | @@ -1,102 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Template used when the installer detects that this is PHP 4 |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup Templates |
8 | | - */ |
9 | | - |
10 | | -if( !defined( 'MW_PHP4' ) ) { |
11 | | - die( "Not an entry point."); |
12 | | -} |
13 | | - |
14 | | -if( isset( $_SERVER['SCRIPT_NAME'] ) ) { |
15 | | - // Probably IIS; doesn't set REQUEST_URI |
16 | | - $scriptUrl = $_SERVER['SCRIPT_NAME']; |
17 | | -} elseif( isset( $_SERVER['REQUEST_URI'] ) ) { |
18 | | - // We're trying SCRIPT_NAME first because it won't include PATH_INFO... hopefully |
19 | | - $scriptUrl = $_SERVER['REQUEST_URI']; |
20 | | -} else { |
21 | | - $scriptUrl = ''; |
22 | | -} |
23 | | -if ( preg_match( '!^(.*)/(mw-)?config/[^/]*.php$!', $scriptUrl, $m ) ) { |
24 | | - $baseUrl = $m[1]; |
25 | | -} elseif ( preg_match( '!^(.*)/[^/]*.php$!', $scriptUrl, $m ) ) { |
26 | | - $baseUrl = $m[1]; |
27 | | -} else { |
28 | | - $baseUrl = dirname( $scriptUrl ); |
29 | | -} |
30 | | - |
31 | | -?> |
32 | | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
33 | | -<html xmlns='http://www.w3.org/1999/xhtml' lang='en'> |
34 | | - <head> |
35 | | - <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?></title> |
36 | | - <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> |
37 | | - <style type='text/css' media='screen'> |
38 | | - html, body { |
39 | | - color: #000; |
40 | | - background-color: #fff; |
41 | | - font-family: sans-serif; |
42 | | - text-align: center; |
43 | | - } |
44 | | - |
45 | | - p { |
46 | | - text-align: left; |
47 | | - margin-left: 2em; |
48 | | - margin-right: 2em; |
49 | | - } |
50 | | - |
51 | | - h1 { |
52 | | - font-size: 150%; |
53 | | - } |
54 | | - </style> |
55 | | - </head> |
56 | | - <body> |
57 | | - <img src="<?php echo htmlspecialchars( $baseUrl ) ?>/skins/common/images/mediawiki.png" alt='The MediaWiki logo' /> |
58 | | - |
59 | | - <h1>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?></h1> |
60 | | - <div class='error'> |
61 | | -<p> |
62 | | - MediaWiki requires PHP 5.2.3 or higher. You are running PHP |
63 | | - <?php echo htmlspecialchars( phpversion() ); ?>. |
64 | | -</p> |
65 | | -<?php |
66 | | -flush(); |
67 | | -/** |
68 | | - * Test the *.php5 extension |
69 | | - */ |
70 | | -$downloadOther = true; |
71 | | -if ( $baseUrl ) { |
72 | | - $testUrl = "$wgServer$baseUrl/php5.php5"; |
73 | | - if( function_exists( 'file_get_contents' ) ) { |
74 | | - $errorLevel = error_reporting(); |
75 | | - error_reporting( $errorLevel & !E_WARNING ); |
76 | | - |
77 | | - ini_set( 'allow_url_fopen', '1' ); |
78 | | - $s = file_get_contents( $testUrl ); |
79 | | - |
80 | | - error_reporting( $errorLevel ); |
81 | | - } |
82 | | - |
83 | | - if ( strpos( $s, 'yes' ) !== false ) { |
84 | | - $encUrl = htmlspecialchars( str_replace( '.php', '.php5', $scriptUrl ) ); |
85 | | - echo "<p>You may be able to use MediaWiki using a <a href=\"$encUrl\">.php5</a> file extension.</p>"; |
86 | | - $downloadOther = false; |
87 | | - } |
88 | | -} |
89 | | -if ( $downloadOther ) { |
90 | | -?> |
91 | | -<p>Please consider |
92 | | -<a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>. |
93 | | -PHP 4 is at the end of its lifecycle and will not receive further security updates.</p> |
94 | | -<p>If for some reason you really really need to run MediaWiki on PHP 4, you will need to |
95 | | -<a href="http://www.mediawiki.org/wiki/Download">download version 1.6.x</a> |
96 | | -from our website. </p> |
97 | | -<?php |
98 | | -} |
99 | | -?> |
100 | | - |
101 | | - </div> |
102 | | - </body> |
103 | | -</html> |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -851,13 +851,20 @@ |
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
855 | | - * Print a simple message and die, returning nonzero to the shell if any. |
856 | | - * Plain die() fails to return nonzero to the shell if you pass a string. |
| 855 | + * Print an error message and die, returning nonzero to the shell if any. Plain die() |
| 856 | + * fails to return nonzero to the shell if you pass a string. Entry points may customise |
| 857 | + * this function to return a prettier error message, but implementations must not assume |
| 858 | + * access to any of the usual MediaWiki infrastructure (AutoLoader, localisation, database, |
| 859 | + * etc). This should not be called directly once $wgFullyInitialised is set; instead, |
| 860 | + * throw an exception and let Exception.php handle whether or not it's possible to show |
| 861 | + * a prettier error. |
857 | 862 | * @param $msg String |
858 | 863 | */ |
859 | | -function wfDie( $msg = '' ) { |
860 | | - echo $msg; |
861 | | - die( 1 ); |
| 864 | +if( !function_exists( 'wfDie' ) ){ |
| 865 | + function wfDie( $msg = '' ) { |
| 866 | + echo $msg; |
| 867 | + die( 1 ); |
| 868 | + } |
862 | 869 | } |
863 | 870 | |
864 | 871 | /** |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -236,32 +236,44 @@ |
237 | 237 | header( 'Pragma: nocache' ); |
238 | 238 | } |
239 | 239 | |
240 | | - $title = Html::element( 'title', null, $this->getPageTitle() ); |
| 240 | + $head = Html::element( 'title', null, $this->getPageTitle() ) . "\n"; |
| 241 | + $head .= Html::inlineStyle( <<<ENDL |
| 242 | + body { |
| 243 | + color: #000; |
| 244 | + background-color: #fff; |
| 245 | + font-family: sans-serif; |
| 246 | + padding: 2em; |
| 247 | + text-align: center; |
| 248 | + } |
| 249 | + p, img, h1 { |
| 250 | + text-align: left; |
| 251 | + margin: 0.5em 0; |
| 252 | + } |
| 253 | + h1 { |
| 254 | + font-size: 120%; |
| 255 | + } |
| 256 | +ENDL |
| 257 | + ); |
241 | 258 | |
242 | | - $left = 'left'; |
243 | | - $right = 'right'; |
244 | 259 | $dir = 'ltr'; |
245 | 260 | $code = 'en'; |
246 | 261 | |
247 | 262 | if ( $wgLang instanceof Language ) { |
248 | | - $left = $wgLang->alignStart(); |
249 | | - $right = $wgLang->alignEnd(); |
250 | 263 | $dir = $wgLang->getDir(); |
251 | 264 | $code = $wgLang->getCode(); |
252 | 265 | } |
253 | 266 | |
254 | 267 | $header = Html::element( 'img', array( |
255 | 268 | 'src' => $wgLogo, |
256 | | - 'style' => "float: $left; margin-$right: 1em;", |
257 | 269 | 'alt' => '' ), $this->getPageTitle() ); |
258 | 270 | |
259 | 271 | $attribs = array( 'dir' => $dir, 'lang' => $code ); |
260 | 272 | |
261 | 273 | return |
262 | 274 | Html::htmlHeader( $attribs ) . |
263 | | - Html::rawElement( 'head', null, $title ) . "\n". |
| 275 | + Html::rawElement( 'head', null, $head ) . "\n". |
264 | 276 | Html::openElement( 'body' ) . "\n" . |
265 | | - Html::rawElement( 'h1', null, $header ) . "\n"; |
| 277 | + $header . "\n"; |
266 | 278 | } |
267 | 279 | |
268 | 280 | /** |
— | — | @@ -338,6 +350,7 @@ |
339 | 351 | |
340 | 352 | if ( $e instanceof MWException ) { |
341 | 353 | try { |
| 354 | + // Try and show the exception prettily, with the normal skin infrastructure |
342 | 355 | $e->report(); |
343 | 356 | } catch ( Exception $e2 ) { |
344 | 357 | // Exception occurred from within exception handler |
— | — | @@ -359,7 +372,7 @@ |
360 | 373 | if ( $cmdLine ) { |
361 | 374 | wfPrintError( $message ); |
362 | 375 | } else { |
363 | | - echo nl2br( htmlspecialchars( $message ) ) . "\n"; |
| 376 | + wfDie( htmlspecialchars( $message ) ) . "\n"; |
364 | 377 | } |
365 | 378 | } |
366 | 379 | } else { |
— | — | @@ -373,7 +386,7 @@ |
374 | 387 | if ( $cmdLine ) { |
375 | 388 | wfPrintError( $message ); |
376 | 389 | } else { |
377 | | - echo nl2br( htmlspecialchars( $message ) ) . "\n"; |
| 390 | + wfDie( htmlspecialchars( $message ) ) . "\n"; |
378 | 391 | } |
379 | 392 | } |
380 | 393 | } |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -2955,7 +2955,7 @@ |
2956 | 2956 | |
2957 | 2957 | $this->error = Html::element( 'span', array( 'dir' => 'ltr' ), $this->error ); |
2958 | 2958 | |
2959 | | - $noconnect = "<p><strong>$sorry</strong><br />$again</p><p><small>$info</small></p>"; |
| 2959 | + $noconnect = "<h1>$sorry</h1><p>$again</p><p><small>$info</small></p>"; |
2960 | 2960 | $text = str_replace( '$1', $this->error, $noconnect ); |
2961 | 2961 | |
2962 | 2962 | if ( $wgShowDBErrorBacktrace ) { |
Index: trunk/phase3/includes/WebStart.php |
— | — | @@ -100,16 +100,6 @@ |
101 | 101 | # Load up some global defines. |
102 | 102 | require_once( "$IP/includes/Defines.php" ); |
103 | 103 | |
104 | | - # Check for PHP 5 |
105 | | - if ( !function_exists( 'version_compare' ) |
106 | | - || version_compare( phpversion(), '5.0.0' ) < 0 |
107 | | - ) { |
108 | | - define( 'MW_PHP4', '1' ); |
109 | | - require( "$IP/includes/DefaultSettings.php" ); |
110 | | - require( "$IP/includes/templates/PHP4.php" ); |
111 | | - exit; |
112 | | - } |
113 | | - |
114 | 104 | # Start the autoloader, so that extensions can derive classes from core files |
115 | 105 | require_once( "$IP/includes/AutoLoader.php" ); |
116 | 106 | } |
— | — | @@ -126,13 +116,31 @@ |
127 | 117 | if ( !defined( 'MW_CONFIG_FILE' ) ) { |
128 | 118 | define('MW_CONFIG_FILE', MWInit::interpretedPath( 'LocalSettings.php' ) ); |
129 | 119 | } |
130 | | - |
| 120 | + |
131 | 121 | # LocalSettings.php is the per site customization file. If it does not exist |
132 | 122 | # the wiki installer needs to be launched or the generated file uploaded to |
133 | 123 | # the root wiki directory |
134 | 124 | if( !file_exists( MW_CONFIG_FILE ) ) { |
135 | | - require_once( "$IP/includes/templates/NoLocalSettings.php" ); |
136 | | - die(); |
| 125 | + $script = $_SERVER['SCRIPT_NAME']; |
| 126 | + $path = htmlspecialchars( str_replace( '//', '/', pathinfo( $script, PATHINFO_DIRNAME ) ) ); |
| 127 | + $ext = htmlspecialchars( pathinfo( $script, PATHINFO_EXTENSION ) ); |
| 128 | + |
| 129 | + # Check to see if the installer is running |
| 130 | + if ( !function_exists( 'session_name' ) ) { |
| 131 | + $installerStarted = false; |
| 132 | + } else { |
| 133 | + session_name( 'mw_installer_session' ); |
| 134 | + $oldReporting = error_reporting( E_ALL & ~E_NOTICE ); |
| 135 | + $success = session_start(); |
| 136 | + error_reporting( $oldReporting ); |
| 137 | + $installerStarted = ( $success && isset( $_SESSION['installData'] ) ); |
| 138 | + } |
| 139 | + |
| 140 | + $please = $installerStarted |
| 141 | + ? "Please <a href=\"$path/mw-config/index.$ext\"> complete the installation</a> and download LocalSettings.php." |
| 142 | + : "Please <a href=\"$path/mw-config/index.$ext\"> set up the wiki</a> first."; |
| 143 | + |
| 144 | + wfDie( "<p>LocalSettings.php not found.</p><p>$please</p>" ); |
137 | 145 | } |
138 | 146 | |
139 | 147 | # Include site settings. $IP may be changed (hopefully before the AutoLoader is invoked) |