r91604 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91603‎ | r91604 | r91605 >
Date:21:05, 6 July 2011
Author:demon
Status:ok
Tags:
Comment:
Followup r91602, forgot svn add
Modified paths:
  • /trunk/phase3/includes/PHPVersionError.php (added) (history)

Diff [purge]

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

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91602Clean up the mess that is wfDie (resolves r85918). wfDie() doesn't exist anym...demon21:01, 6 July 2011

Status & tagging log