40 'mb_substr' =>
'mbstring',
41 'xml_parser_create' =>
'xml',
42 'ctype_digit' =>
'ctype',
43 'json_decode' =>
'json',
45 'mime_content_type' =>
'fileinfo',
46 'intl_is_failure' =>
'intl',
81 $minimumVersion =
'7.3.19';
98 'T243667, T291127' =>
'7.4.0 - 7.4.2'
101 $passes = version_compare( PHP_VERSION, $minimumVersion,
'>=' );
103 $versionString =
"PHP $minimumVersion or higher";
106 if ( count( $knownBad ) ) {
107 $versionString .=
' (and not ' . implode(
', ', array_values( $knownBad ) ) .
')';
109 foreach ( $knownBad as $task => $range ) {
111 if ( strpos( $range,
'-' ) ) {
112 $passes = $passes && !(
113 version_compare( PHP_VERSION, trim( strstr( $range,
'-',
true ) ),
'>=' )
114 && version_compare( PHP_VERSION, trim( substr( strstr( $range,
'-',
false ), 1 ) ),
'<' )
117 $passes = $passes && version_compare( PHP_VERSION, trim( $range ),
'<>' );
123 $cliText =
"Error: You are using an unsupported PHP version (PHP " . PHP_VERSION .
").\n"
124 .
"MediaWiki $this->mwVersion needs $versionString.\n\nCheck if you might have a newer "
125 .
"PHP executable with a different name.\n\n";
128 $web[
'intro'] =
"MediaWiki $this->mwVersion requires $versionString; you are using PHP "
131 $web[
'longTitle'] =
"Supported PHP versions";
133 $web[
'longHtml'] = <<<HTML
135 Please consider <a href=
"https://www.php.net/downloads.php">upgrading your copy of PHP</a>.
136 PHP versions less than v7.3.0 are no longer supported by the PHP Group and will not receive
137 security or bugfix updates.
140 If
for some reason you are unable to upgrade your PHP version, you will need to
141 <a href=
"https://www.mediawiki.org/wiki/Download">download</a> an older version of
143 <a href=
"https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
144 for details of which versions are compatible with prior versions of PHP.
159 if ( !file_exists( dirname( __FILE__ ) .
'/../vendor/autoload.php' ) ) {
160 $cliText =
"Error: You are missing some external dependencies. \n"
161 .
"MediaWiki also has some external dependencies that need to be installed\n"
162 .
"via composer or from a separate git repo. Please see\n"
163 .
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
164 .
"for help on installing the required components.";
167 $web[
'intro'] =
"Installing some external dependencies (e.g. via composer) is required.";
168 $web[
'longTitle'] =
'External dependencies';
170 $web[
'longHtml'] = <<<HTML
172 MediaWiki also has some external dependencies that need to be installed via
173 composer or from a separate git repo. Please see the
174 <a href=
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">instructions
175 for installing libraries</a> on mediawiki.org
for help on installing the required components.
188 $missingExtensions = array();
189 foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
190 if ( !function_exists( $function ) ) {
191 $missingExtensions[] = $extension;
195 if ( $missingExtensions ) {
196 $missingExtText =
'';
197 $missingExtHtml =
'';
198 $baseUrl =
'https://www.php.net';
199 foreach ( $missingExtensions as
$ext ) {
200 $missingExtText .=
" * $ext <$baseUrl/$ext>\n";
201 $missingExtHtml .=
"<li><b>$ext</b> "
202 .
"(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
205 $cliText =
"Error: Missing one or more required components of PHP.\n"
206 .
"You are missing a required extension to PHP that MediaWiki needs.\n"
207 .
"Please install:\n" . $missingExtText;
210 $web[
'intro'] =
"Installing some PHP extensions is required.";
211 $web[
'longTitle'] =
'Required components';
212 $web[
'longHtml'] = <<<HTML
214 You are missing a required extension to PHP that
MediaWiki
215 requires to run. Please install:
230 $protocol = isset( $_SERVER[
'SERVER_PROTOCOL'] ) ? $_SERVER[
'SERVER_PROTOCOL'] :
'HTTP/1.0';
232 header(
"$protocol 500 MediaWiki configuration Error" );
234 header(
'Cache-control: none' );
235 header(
'Pragma: no-cache' );
248 htmlspecialchars( str_replace(
'//',
'/', $this->scriptPath .
'/' ) .
249 'resources/assets/mediawiki.png' );
251 $introHtml = htmlspecialchars( $introText );
252 $longTitleHtml = htmlspecialchars( $longTitle );
254 header(
'Content-type: text/html; charset=UTF-8' );
256 $finalOutput = <<<HTML
258<html lang=
"en" dir=
"ltr">
260 <meta charset=
"UTF-8" />
261 <title>
MediaWiki {$this->mwVersion}</title>
262 <style media=
"screen">
265 background-color: #fff;
266 font-family: sans-serif;
283 <img src=
"{$encLogo}" alt=
"The MediaWiki logo" />
284 <h1>
MediaWiki {$this->mwVersion}
internal error</h1>
288 <h2>{$longTitleHtml}</h2>
312 if ( $this->format ===
'html' ) {
322 $finalOutput = $cliText;
325 echo
"$finalOutput\n";
339 $phpVersionCheck->setFormat( $format );
340 $phpVersionCheck->setScriptPath( $scriptPath );
341 $phpVersionCheck->checkRequiredPHPVersion();
342 $phpVersionCheck->checkVendorExistence();
343 $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...
setFormat( $format)
Set the format used for errors.
string $mwVersion
The number of the MediaWiki version used.
outputHTMLHeader()
Output headers that prevents error pages to be cached.
setScriptPath( $scriptPath)
Set the script path used for images in HTML-formatted errors.
triggerError( $web, $cliText)
Display something vaguely comprehensible in the event of a totally unrecoverable error.
getIndexErrorOutput( $introText, $longTitle, $longHtml)
Returns an error page, which is suitable for output to the end user via a web browser.
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.
string[] $functionsExtensionsMapping
A mapping of PHP functions to PHP extensions.
checkVendorExistence()
Displays an error, if the vendor/autoload.php file could not be found.
string $format
The format used for errors.
if(!is_readable( $file)) $ext