40 'mb_substr' =>
'mbstring',
41 'xml_parser_create' =>
'xml',
42 'ctype_digit' =>
'ctype',
43 'json_decode' =>
'json',
45 'mime_content_type' =>
'fileinfo',
80 $minimumVersion =
'7.3.19';
97 'T243667, T291127' =>
'7.4.0 - 7.4.2'
100 $passes = version_compare( PHP_VERSION, $minimumVersion,
'>=' );
102 $versionString =
"PHP $minimumVersion or higher";
105 if ( count( $knownBad ) ) {
106 $versionString .=
' (and not ' . implode(
', ', array_values( $knownBad ) ) .
')';
108 foreach ( $knownBad as $task => $range ) {
110 if ( strpos( $range,
'-' ) ) {
111 $passes = $passes && !(
112 version_compare( PHP_VERSION, trim( strstr( $range,
'-',
true ) ),
'>=' )
113 && version_compare( PHP_VERSION, trim( substr( strstr( $range,
'-',
false ), 1 ) ),
'<' )
116 $passes = $passes && version_compare( PHP_VERSION, trim( $range ),
'<>' );
122 $cliText =
"Error: You are using an unsupported PHP version (PHP " . PHP_VERSION .
").\n"
123 .
"MediaWiki $this->mwVersion needs $versionString.\n\nCheck if you might have a newer "
124 .
"PHP executable with a different name.\n\n";
127 $web[
'intro'] =
"MediaWiki $this->mwVersion requires $versionString; you are using PHP "
130 $web[
'longTitle'] =
"Supported PHP versions";
132 $web[
'longHtml'] = <<<HTML
134 Please consider <a href=
"https://www.php.net/downloads.php">upgrading your copy of PHP</a>.
135 PHP versions less than v7.3.0 are no longer supported by the PHP Group and will not receive
136 security or bugfix updates.
139 If
for some reason you are unable to upgrade your PHP version, you will need to
140 <a href=
"https://www.mediawiki.org/wiki/Download">download</a> an older version of
142 <a href=
"https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
143 for details of which versions are compatible with prior versions of PHP.
158 if ( !file_exists( dirname( __FILE__ ) .
'/../vendor/autoload.php' ) ) {
159 $cliText =
"Error: You are missing some external dependencies. \n"
160 .
"MediaWiki also has some external dependencies that need to be installed\n"
161 .
"via composer or from a separate git repo. Please see\n"
162 .
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
163 .
"for help on installing the required components.";
166 $web[
'intro'] =
"Installing some external dependencies (e.g. via composer) is required.";
167 $web[
'longTitle'] =
'External dependencies';
169 $web[
'longHtml'] = <<<HTML
171 MediaWiki also has some external dependencies that need to be installed via
172 composer or from a separate git repo. Please see the
173 <a href=
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">instructions
174 for installing libraries</a> on mediawiki.org
for help on installing the required components.
187 $missingExtensions = array();
188 foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
189 if ( !function_exists( $function ) ) {
190 $missingExtensions[] = $extension;
194 if ( $missingExtensions ) {
195 $missingExtText =
'';
196 $missingExtHtml =
'';
197 $baseUrl =
'https://www.php.net';
198 foreach ( $missingExtensions as
$ext ) {
199 $missingExtText .=
" * $ext <$baseUrl/$ext>\n";
200 $missingExtHtml .=
"<li><b>$ext</b> "
201 .
"(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
204 $cliText =
"Error: Missing one or more required components of PHP.\n"
205 .
"You are missing a required extension to PHP that MediaWiki needs.\n"
206 .
"Please install:\n" . $missingExtText;
209 $web[
'intro'] =
"Installing some PHP extensions is required.";
210 $web[
'longTitle'] =
'Required components';
211 $web[
'longHtml'] = <<<HTML
213 You are missing a required extension to PHP that
MediaWiki
214 requires to run. Please install:
229 $protocol = isset( $_SERVER[
'SERVER_PROTOCOL'] ) ? $_SERVER[
'SERVER_PROTOCOL'] :
'HTTP/1.0';
231 header(
"$protocol 500 MediaWiki configuration Error" );
233 header(
'Cache-control: none' );
234 header(
'Pragma: no-cache' );
247 htmlspecialchars( str_replace(
'//',
'/', $this->scriptPath .
'/' ) .
248 'resources/assets/mediawiki.png' );
250 $introHtml = htmlspecialchars( $introText );
251 $longTitleHtml = htmlspecialchars( $longTitle );
253 header(
'Content-type: text/html; charset=UTF-8' );
255 $finalOutput = <<<HTML
257<html lang=
"en" dir=
"ltr">
259 <meta charset=
"UTF-8" />
260 <title>
MediaWiki {$this->mwVersion}</title>
261 <style media=
"screen">
264 background-color: #fff;
265 font-family: sans-serif;
282 <img src=
"{$encLogo}" alt=
"The MediaWiki logo" />
283 <h1>
MediaWiki {$this->mwVersion}
internal error</h1>
287 <h2>{$longTitleHtml}</h2>
311 if ( $this->format ===
'html' ) {
321 $finalOutput = $cliText;
324 echo
"$finalOutput\n";
338 $phpVersionCheck->setFormat( $format );
339 $phpVersionCheck->setScriptPath( $scriptPath );
340 $phpVersionCheck->checkRequiredPHPVersion();
341 $phpVersionCheck->checkVendorExistence();
342 $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.
checkVendorExistence()
Displays an error, if the vendor/autoload.php file could not be found.
$functionsExtensionsMapping
string $format
The format used for errors.
if(!is_readable( $file)) $ext