From b3f9120af5fc883b38d5e7b55368ff61c2bbdd09 Mon Sep 17 00:00:00 2001
From: paladox
- {$message}
+ {$shortHtml}
+ {$longHtml}
+ tag
+ * @param string $shortText
+ * @param string $longText
+ * @param string $longHtml
*/
-function wfPHPVersionError( $type ) {
- $mwVersion = '1.26';
- $minimumVersionPHP = '5.3.3';
-
- $phpVersion = PHP_VERSION;
+function wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $longHtml ) {
$protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
- $message = "MediaWiki $mwVersion requires at least "
- . "PHP version $minimumVersionPHP, you are using PHP $phpVersion. Installing some "
- . " external dependencies (e.g. via composer) is also required.";
if ( $type == 'cli' ) {
- $finalOutput = "Error: You are missing some external dependencies or are using on older PHP version. \n"
- . "MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher.\n\n"
- . "Check if you have a newer php executable with a different name, such as php5.\n\n"
- . "MediaWiki now also has some external dependencies that need to be installed\n"
- . "via composer or from a separate git repo. Please see\n"
- . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
- . "for help on installing the required components.";
- } elseif ( $type == 'index.php' || $type == 'mw-config/index.php' ) {
- $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] );
- if ( $type == 'mw-config/index.php' ) {
- $dirname = dirname( $pathinfo['dirname'] );
- } else {
- $dirname = $pathinfo['dirname'];
- }
- $encLogo = htmlspecialchars(
- str_replace( '//', '/', $dirname . '/' ) .
- 'resources/assets/mediawiki.png'
- );
-
+ $finalOutput = $longText;
+ } else {
header( "$protocol 500 MediaWiki configuration Error" );
- header( 'Content-type: text/html; charset=UTF-8' );
// Don't cache error pages! They cause no end of trouble...
header( 'Cache-control: none' );
header( 'Pragma: no-cache' );
- $finalOutput = <<
@@ -120,10 +122,43 @@ function wfPHPVersionError( $type ) {
MediaWiki {$mwVersion} internal error
Supported PHP versions
+ {$title}
+HTML; + wfGenericError( $type, $mwVersion, 'Supported PHP versions', $shortText, $longText, $longHtml ); +} + +/** + * Display an error for the vendor/autoload.php file not being found. + * + * @param string $type See wfGenericError + * @param string $mwVersion See wfGenericError + */ +function wfMissingVendorError( $type, $mwVersion ) { + $shortText = "Installing some external dependencies (e.g. via composer) is also required."; + + $longText = "Error: You are missing some external dependencies. \n" + . "MediaWiki now also has some external dependencies that need to be installed\n" + . "via composer or from a separate git repo. Please see\n" + . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n" + . "for help on installing the required components."; + + $longHtml = <<mediawiki.org for help on installing the required components. -
- - - HTML; - // Handle everything that's not index.php - } else { - // So nothing thinks this is JS or CSS - $finalOutput = ( $type == 'load.php' ) ? "/* $message */" : $message; - header( "$protocol 500 MediaWiki configuration Error" ); - } - echo "$finalOutput\n"; - die( 1 ); + + wfGenericError( $type, $mwVersion, 'External dependencies', $shortText, $longText, $longHtml ); } -- 2.20.1