(bug 35565) Special:Log/patrol doesn't indicate whether patrolling was automatic
[mediawiki.git] / includes / PHPVersionError.php
blobec6490a8b07b8604f890c608f261e74cd2d00ffe
1 <?php
2 /**
3 * Display something vaguely comprehensible in the event of a totally unrecoverable error.
4 * Does not assume access to *anything*; no globals, no autloader, no database, no localisation.
5 * Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php
6 * no longer need to be).
8 * Calling this function kills execution immediately.
10 * @param $type String Which entry point we are protecting. One of:
11 * - index.php
12 * - load.php
13 * - api.php
14 * - cli
16 * @note Since we can't rely on anything, the minimum PHP versions and MW current
17 * version are hardcoded here
19 function wfPHPVersionError( $type ){
20 $mwVersion = '1.19';
21 $phpVersion = PHP_VERSION;
22 $message = "MediaWiki $mwVersion requires at least PHP version 5.2.3, you are using PHP $phpVersion.";
23 if( $type == 'index.php' ) {
24 $encLogo = htmlspecialchars(
25 str_replace( '//', '/', pathinfo( $_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME ) . '/'
26 ) . 'skins/common/images/mediawiki.png'
29 header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 );
30 header( 'Content-type: text/html; charset=UTF-8' );
31 // Don't cache error pages! They cause no end of trouble...
32 header( 'Cache-control: none' );
33 header( 'Pragma: nocache' );
35 $finalOutput = <<<HTML
36 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
37 <html xmlns='http://www.w3.org/1999/xhtml' lang='en'>
38 <head>
39 <title>MediaWiki {$mwVersion}</title>
40 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
41 <style type='text/css' media='screen'>
42 body {
43 color: #000;
44 background-color: #fff;
45 font-family: sans-serif;
46 padding: 2em;
47 text-align: center;
49 p, img, h1 {
50 text-align: left;
51 margin: 0.5em 0;
53 h1 {
54 font-size: 120%;
56 </style>
57 </head>
58 <body>
59 <img src="{$encLogo}" alt='The MediaWiki logo' />
60 <h1>MediaWiki {$mwVersion} internal error</h1>
61 <div class='error'>
62 <p>
63 {$message}
64 </p>
65 <p>
66 Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>.
67 PHP versions less than 5.3.0 are no longer supported by the PHP Group and will not receive
68 security or bugfix updates.
69 </p>
70 <p>
71 If for some reason you are unable to upgrade your PHP version, you will need to
72 <a href="http://www.mediawiki.org/wiki/Download">download</a> an older version
73 of MediaWiki from our website. See our
74 <a href="http://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
75 for details of which versions are compatible with prior versions of PHP.
76 </p>
77 </div>
78 </body>
79 </html>
80 HTML;
81 // Handle everything that's not index.php
82 } else {
83 // So nothing thinks this is JS or CSS
84 $finalOutput = ( $type == 'load.php' ) ? "/* $message */" : $message;
85 if( $type != 'cli' ) {
86 header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 );
89 echo( "$finalOutput\n" );
90 die( 1 );