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.4.3';
98 $passes = version_compare( PHP_VERSION, $minimumVersion,
'>=' );
100 $versionString =
"PHP $minimumVersion or higher";
103 if ( count( $knownBad ) ) {
104 $versionString .=
' (and not ' . implode(
', ', array_values( $knownBad ) ) .
')';
106 foreach ( $knownBad as $task => $range ) {
108 if ( strpos( $range,
'-' ) ) {
109 $passes = $passes && !(
110 version_compare( PHP_VERSION, trim( strstr( $range,
'-',
true ) ),
'>=' )
111 && version_compare( PHP_VERSION, trim( substr( strstr( $range,
'-',
false ), 1 ) ),
'<' )
114 $passes = $passes && version_compare( PHP_VERSION, trim( $range ),
'<>' );
120 $cliText =
"Error: You are using an unsupported PHP version (PHP " . PHP_VERSION .
").\n"
121 .
"MediaWiki $this->mwVersion needs $versionString.\n\nCheck if you might have a newer "
122 .
"PHP executable with a different name.\n\n";
125 $web[
'intro'] =
"MediaWiki $this->mwVersion requires $versionString; you are using PHP "
128 $web[
'longTitle'] =
"Supported PHP versions";
130 $web[
'longHtml'] = <<<HTML
132 Please consider <a href=
"https://www.php.net/downloads.php">upgrading your copy of PHP</a>.
133 PHP versions less than v8.1.0 are no longer <a href=
"https://www.php.net/supported-versions.php">supported</a>
134 by the PHP Group and will not receive security or bugfix updates.
137 If
for some reason you are unable to upgrade your PHP version, you will need to
138 <a href=
"https://www.mediawiki.org/wiki/Download">download</a> an older version of
140 <a href=
"https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
141 for details of which versions are compatible with prior versions of PHP.
156 if ( !file_exists( dirname( __FILE__ ) .
'/../vendor/autoload.php' ) ) {
157 $cliText =
"Error: You are missing some external dependencies. \n"
158 .
"MediaWiki also has some external dependencies that need to be installed\n"
159 .
"via composer or from a separate git repo. Please see\n"
160 .
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
161 .
"for help on installing the required components.";
164 $web[
'intro'] =
"Installing some external dependencies (e.g. via composer) is required.";
165 $web[
'longTitle'] =
'External dependencies';
167 $web[
'longHtml'] = <<<HTML
169 MediaWiki also has some external dependencies that need to be installed via
170 composer or from a separate git repo. Please see the
171 <a href=
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">instructions
172 for installing libraries</a> on mediawiki.org
for help on installing the required components.
185 $missingExtensions = array();
186 foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
187 if ( !function_exists( $function ) ) {
188 $missingExtensions[] = $extension;
192 if ( $missingExtensions ) {
193 $missingExtText =
'';
194 $missingExtHtml =
'';
195 $baseUrl =
'https://www.php.net';
196 foreach ( $missingExtensions as
$ext ) {
197 $missingExtText .=
" * $ext <$baseUrl/$ext>\n";
198 $missingExtHtml .=
"<li><b>$ext</b> "
199 .
"(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
202 $cliText =
"Error: Missing one or more required components of PHP.\n"
203 .
"You are missing a required extension to PHP that MediaWiki needs.\n"
204 .
"Please install:\n" . $missingExtText;
207 $web[
'intro'] =
"Installing some PHP extensions is required.";
208 $web[
'longTitle'] =
'Required components';
209 $web[
'longHtml'] = <<<HTML
211 You are missing a required extension to PHP that
MediaWiki
212 requires to run. Please install:
227 $protocol = isset( $_SERVER[
'SERVER_PROTOCOL'] ) ? $_SERVER[
'SERVER_PROTOCOL'] :
'HTTP/1.0';
229 header(
"$protocol 500 MediaWiki configuration Error" );
231 header(
'Cache-control: none' );
232 header(
'Pragma: no-cache' );
245 htmlspecialchars( str_replace(
'//',
'/', $this->scriptPath .
'/' ) .
246 'resources/assets/mediawiki.png' );
248 $introHtml = htmlspecialchars( $introText );
249 $longTitleHtml = htmlspecialchars( $longTitle );
251 header(
'Content-type: text/html; charset=UTF-8' );
253 $finalOutput = <<<HTML
255<html lang=
"en" dir=
"ltr">
257 <meta charset=
"UTF-8" />
258 <title>
MediaWiki {$this->mwVersion}</title>
259 <style media=
"screen">
262 background-color: #fff;
263 font-family: sans-serif;
280 <img src=
"{$encLogo}" alt=
"The MediaWiki logo" />
281 <h1>
MediaWiki {$this->mwVersion}
internal error</h1>
285 <h2>{$longTitleHtml}</h2>
309 if ( $this->format ===
'html' ) {
319 $finalOutput = $cliText;
322 echo
"$finalOutput\n";
336 $phpVersionCheck->setFormat( $format );
337 $phpVersionCheck->setScriptPath( $scriptPath );
338 $phpVersionCheck->checkRequiredPHPVersion();
339 $phpVersionCheck->checkVendorExistence();
340 $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