27 'mb_substr' =>
'mbstring',
28 'xml_parser_create' =>
'xml',
29 'ctype_digit' =>
'ctype',
30 'json_decode' =>
'json',
32 'mime_content_type' =>
'fileinfo',
33 'intl_is_failure' =>
'intl',
70 $minimumVersion =
'8.2.0';
88 $passes = version_compare( PHP_VERSION, $minimumVersion,
'>=' );
90 $versionString =
"PHP $minimumVersion or higher";
93 if ( count( $knownBad ) ) {
94 $versionString .=
' (and not ' . implode(
', ', array_values( $knownBad ) ) .
')';
96 foreach ( $knownBad as $range ) {
98 if ( strpos( $range,
'-' ) ) {
99 $passes = $passes && !(
100 version_compare( PHP_VERSION, trim( strstr( $range,
'-',
true ) ),
'>=' )
101 && version_compare( PHP_VERSION, trim( substr( strstr( $range,
'-',
false ), 1 ) ),
'<' )
104 $passes = $passes && version_compare( PHP_VERSION, trim( $range ),
'<>' );
110 $cliText =
"Error: You are using an unsupported PHP version (PHP " . PHP_VERSION .
").\n"
111 .
"MediaWiki $this->mwVersion needs $versionString.\n\nCheck if you might have a newer "
112 .
"PHP executable with a different name.\n\n";
115 $web[
'intro'] =
"MediaWiki $this->mwVersion requires $versionString; you are using PHP "
118 $web[
'longTitle'] =
"Supported PHP versions";
120 $web[
'longHtml'] = <<<HTML
122 Please consider <a href=
"https://www.php.net/downloads.php">upgrading your copy of PHP</a>.
123 PHP versions less than v8.2.0 are no longer <a href=
"https://www.php.net/supported-versions.php">supported</a>
124 by the PHP Group and will not receive security or bugfix updates.
127 If
for some reason you are unable to upgrade your PHP version, you will need to
128 <a href=
"https://www.mediawiki.org/wiki/Download">download</a> an older version of
130 <a href=
"https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
131 for details of which versions are compatible with prior versions of PHP.
146 if ( !file_exists( dirname( __FILE__ ) .
'/../vendor/autoload.php' ) ) {
147 $cliText =
"Error: You are missing some dependencies. \n"
148 .
"MediaWiki has dependencies that need to be installed via Composer\n"
149 .
"or from a separate repository. Please see\n"
150 .
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
151 .
"for help with installing them.";
154 $web[
'intro'] =
"Installing some dependencies is required.";
155 $web[
'longTitle'] =
'Dependencies';
157 $web[
'longHtml'] = <<<HTML
159 MediaWiki has dependencies that need to be installed via Composer
160 or from a separate repository. Please see the
161 <a href=
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">instructions
162 for installing external libraries</a> on
MediaWiki.org.
175 $missingExtensions = array();
176 foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
177 if ( !function_exists( $function ) ) {
178 $missingExtensions[] = array( $extension );
183 if ( PHP_INT_SIZE < 8 && !extension_loaded(
'gmp' ) && !extension_loaded(
'bcmath' ) ) {
184 $missingExtensions[] = array(
'bcmath',
'gmp' );
187 if ( $missingExtensions ) {
188 $missingExtText =
'';
189 $missingExtHtml =
'';
190 $baseUrl =
'https://www.php.net';
191 foreach ( $missingExtensions as $extNames ) {
192 $plaintextLinks = array();
193 $htmlLinks = array();
194 foreach ( $extNames as $ext ) {
195 $plaintextLinks[] =
"$ext <$baseUrl/$ext>";
196 $htmlLinks[] =
"<b>$ext</b> (<a href=\"$baseUrl/$ext\">more information</a>)";
199 $missingExtText .=
' * ' . implode(
' or ', $plaintextLinks ) .
"\n";
200 $missingExtHtml .=
"<li>" . implode(
' or ', $htmlLinks ) .
"</li>";
203 $cliText =
"Error: Missing one or more required PHP extensions. Please see\n"
204 .
"https://www.mediawiki.org/wiki/Manual:Installation_requirements#PHP\n"
205 .
"for help with installing them.\n"
206 .
"Please install or enable:\n" . $missingExtText;
209 $web[
'intro'] =
"Installing some PHP extensions is required.";
210 $web[
'longTitle'] =
'Required PHP extensions';
211 $web[
'longHtml'] = <<<HTML
213 You are missing one or more extensions to PHP that
MediaWiki requires to run. Please see the
214 <a href=
"https://www.mediawiki.org/wiki/Manual:Installation_requirements#PHP">PHP
215 installation requirements</a> on
MediaWiki.org.
217 <p>Please install or enable:</p>
231 $protocol = isset( $_SERVER[
'SERVER_PROTOCOL'] ) ? $_SERVER[
'SERVER_PROTOCOL'] :
'HTTP/1.0';
233 header(
"$protocol 500 MediaWiki configuration Error" );
235 header(
'Cache-Control: 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.