41 'mb_substr' =>
'mbstring',
42 'xml_parser_create' =>
'xml',
43 'ctype_digit' =>
'ctype',
44 'json_decode' =>
'json',
46 'mime_content_type' =>
'fileinfo',
94 'implementation' =>
'PHP',
95 'version' => PHP_VERSION,
96 'vendor' =>
'the PHP Group',
97 'upstreamSupported' =>
'7.2.0',
98 'minSupported' =>
'7.2.9',
99 'upgradeURL' =>
'https://www.php.net/downloads.php',
108 $minimumVersion = $phpInfo[
'minSupported'];
109 if ( version_compare( $phpInfo[
'version'], $minimumVersion ) < 0 ) {
110 $shortText =
"MediaWiki $this->mwVersion requires at least {$phpInfo['implementation']}"
111 .
" version $minimumVersion, you are using {$phpInfo['implementation']} "
112 .
"{$phpInfo['version']}.";
114 $longText =
"Error: You might be using an older {$phpInfo['implementation']} version "
115 .
"({$phpInfo['implementation']} {$phpInfo['version']}). \n"
116 .
"MediaWiki $this->mwVersion needs {$phpInfo['implementation']}"
117 .
" $minimumVersion or higher.\n\nCheck if you have a"
118 .
" newer PHP executable with a different name.\n\n";
122 Please consider <a href=
"{$phpInfo['upgradeURL']}">upgrading your copy of
123 {$phpInfo[
'implementation']}</a>.
124 {$phpInfo[
'implementation']} versions less than {$phpInfo[
'upstreamSupported']} are no
125 longer supported by {$phpInfo[
'vendor']} and will not receive
126 security or bugfix updates.
129 If
for some reason you are unable to upgrade your {$phpInfo[
'implementation']} version,
130 you will need to <a href=
"https://www.mediawiki.org/wiki/Download">download</a> an
131 older version of
MediaWiki from our website.
132 See our <a href=
"https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
133 for details of which versions are compatible with prior versions of {$phpInfo[
'implementation']}.
137 "Supported {$phpInfo['implementation']} versions",
149 if ( !file_exists( dirname( __FILE__ ) .
'/../vendor/autoload.php' ) ) {
150 $shortText =
"Installing some external dependencies (e.g. via composer) is required.";
152 $longText =
"Error: You are missing some external dependencies. \n"
153 .
"MediaWiki now also has some external dependencies that need to be installed\n"
154 .
"via composer or from a separate git repo. Please see\n"
155 .
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
156 .
"for help on installing the required components.";
160 MediaWiki now also has some external dependencies that need to be installed via
161 composer or from a separate git repo. Please see
162 <a href=
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">mediawiki.org</a>
163 for help on installing the required components.
167 $this->
triggerError(
'External dependencies', $shortText, $longText, $longHtml );
175 $missingExtensions = array();
176 foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
177 if ( !function_exists( $function ) ) {
178 $missingExtensions[] = $extension;
182 if ( $missingExtensions ) {
183 $shortText =
"Installing some PHP extensions is required.";
185 $missingExtText =
'';
186 $missingExtHtml =
'';
187 $baseUrl =
'https://www.php.net';
188 foreach ( $missingExtensions as
$ext ) {
189 $missingExtText .=
" * $ext <$baseUrl/$ext>\n";
190 $missingExtHtml .=
"<li><b>$ext</b> "
191 .
"(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
194 $cliText =
"Error: Missing one or more required components of PHP.\n"
195 .
"You are missing a required extension to PHP that MediaWiki needs.\n"
196 .
"Please install:\n" . $missingExtText;
199 You are missing a required extension to PHP that
MediaWiki
200 requires to run. Please install:
206 $this->
triggerError(
'Required components', $shortText, $cliText, $longHtml );
214 $protocol = isset( $_SERVER[
'SERVER_PROTOCOL'] ) ? $_SERVER[
'SERVER_PROTOCOL'] :
'HTTP/1.0';
216 header(
"$protocol 500 MediaWiki configuration Error" );
218 header(
'Cache-control: none' );
219 header(
'Pragma: no-cache' );
232 htmlspecialchars( str_replace(
'//',
'/', $this->scriptPath .
'/' ) .
233 'resources/assets/mediawiki.png' );
234 $shortHtml = htmlspecialchars( $shortText );
236 header(
'Content-type: text/html; charset=UTF-8' );
238 $finalOutput = <<<HTML
240<html lang=
"en" dir=
"ltr">
242 <meta charset=
"UTF-8" />
243 <title>
MediaWiki {$this->mwVersion}</title>
244 <style media=
"screen">
247 background-color: #fff;
248 font-family: sans-serif;
265 <img src=
"{$encLogo}" alt=
"The MediaWiki logo" />
266 <h1>
MediaWiki {$this->mwVersion}
internal error</h1>
297 if ( $this->format ===
'html' ) {
303 $finalOutput = $longText;
306 echo
"$finalOutput\n";
320 $phpVersionCheck->setFormat( $format );
321 $phpVersionCheck->setScriptPath( $scriptPath );
322 $phpVersionCheck->checkRequiredPHPVersion();
323 $phpVersionCheck->checkVendorExistence();
324 $phpVersionCheck->checkExtensionExistence();
wfEntryPointCheck( $format='text', $scriptPath='/')
Check PHP version and that external dependencies are installed, and display an informative error if e...
Check PHP Version, as well as for composer dependencies in entry points, and display something vaguel...
triggerError( $title, $shortText, $longText, $longHtml)
Display something vaguely comprehensible in the event of a totally unrecoverable error.
setFormat( $format)
Set the format used for errors.
getPHPInfo()
Return the version of the installed PHP implementation.
outputHTMLHeader()
Output headers that prevents error pages to be cached.
setScriptPath( $scriptPath)
Set the script path used for images in HTML-formatted errors.
checkExtensionExistence()
Displays an error, if a PHP extension does not exist.
checkRequiredPHPVersion()
Displays an error, if the installed PHP version does not meet the minimum requirement.
checkVendorExistence()
Displays an error, if the vendor/autoload.php file could not be found.
$functionsExtensionsMapping
getIndexErrorOutput( $title, $longHtml, $shortText)
Returns an error page, which is suitable for output to the end user via a web browser.
if(!is_readable( $file)) $ext