27 'mb_substr' =>
'mbstring',
28 'xml_parser_create' =>
'xml',
29 'ctype_digit' =>
'ctype',
31 'mime_content_type' =>
'fileinfo',
32 'intl_is_failure' =>
'intl',
68 $minimumVersion =
'8.2.0';
86 $passes = version_compare( PHP_VERSION, $minimumVersion,
'>=' );
88 $versionString =
"PHP $minimumVersion or higher";
91 if ( count( $knownBad ) ) {
92 $versionString .=
' (and not ' . implode(
', ', array_values( $knownBad ) ) .
')';
94 foreach ( $knownBad as $range ) {
96 if ( strpos( $range,
'-' ) ) {
97 $passes = $passes && !(
98 version_compare( PHP_VERSION, trim( strstr( $range,
'-',
true ) ),
'>=' )
99 && version_compare( PHP_VERSION, trim( substr( strstr( $range,
'-',
false ), 1 ) ),
'<' )
102 $passes = $passes && version_compare( PHP_VERSION, trim( $range ),
'<>' );
108 $cliText =
"Error: You are using an unsupported PHP version (PHP " . PHP_VERSION .
").\n"
109 .
"MediaWiki $this->mwVersion needs $versionString.\n\nCheck if you might have a newer "
110 .
"PHP executable with a different name.\n\n";
113 $web[
'intro'] =
"MediaWiki $this->mwVersion requires $versionString; you are using PHP "
116 $web[
'longTitle'] =
"Supported PHP versions";
118 $web[
'longHtml'] = <<<HTML
120 Please consider <a href=
"https://www.php.net/downloads.php">upgrading your copy of PHP</a>.
121 PHP versions less than v8.2.0 are no longer <a href=
"https://www.php.net/supported-versions.php">supported</a>
122 by the PHP Group and will not receive security or bugfix updates.
125 If
for some reason you are unable to upgrade your PHP version, you will need to
126 <a href=
"https://www.mediawiki.org/wiki/Download">download</a> an older version of
128 <a href=
"https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
129 for details of which versions are compatible with prior versions of PHP.
144 if ( !file_exists( dirname( __FILE__ ) .
'/../vendor/autoload.php' ) ) {
145 $cliText =
"Error: You are missing some dependencies. \n"
146 .
"MediaWiki has dependencies that need to be installed via Composer\n"
147 .
"or from a separate repository. Please see\n"
148 .
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
149 .
"for help with installing them.";
152 $web[
'intro'] =
"Installing some dependencies is required.";
153 $web[
'longTitle'] =
'Dependencies';
155 $web[
'longHtml'] = <<<HTML
157 MediaWiki has dependencies that need to be installed via Composer
158 or from a separate repository. Please see the
159 <a href=
"https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">instructions
160 for installing external libraries</a> on
MediaWiki.org.
173 $missingExtensions = array();
174 foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
175 if ( !function_exists( $function ) ) {
176 $missingExtensions[] = array( $extension );
181 if ( PHP_INT_SIZE < 8 && !extension_loaded(
'gmp' ) && !extension_loaded(
'bcmath' ) ) {
182 $missingExtensions[] = array(
'bcmath',
'gmp' );
185 if ( $missingExtensions ) {
186 $missingExtText =
'';
187 $missingExtHtml =
'';
188 $baseUrl =
'https://www.php.net';
189 foreach ( $missingExtensions as $extNames ) {
190 $plaintextLinks = array();
191 $htmlLinks = array();
192 foreach ( $extNames as $ext ) {
193 $plaintextLinks[] =
"$ext <$baseUrl/$ext>";
194 $htmlLinks[] =
"<b>$ext</b> (<a href=\"$baseUrl/$ext\">more information</a>)";
197 $missingExtText .=
' * ' . implode(
' or ', $plaintextLinks ) .
"\n";
198 $missingExtHtml .=
"<li>" . implode(
' or ', $htmlLinks ) .
"</li>";
201 $cliText =
"Error: Missing one or more required PHP extensions. Please see\n"
202 .
"https://www.mediawiki.org/wiki/Manual:Installation_requirements#PHP\n"
203 .
"for help with installing them.\n"
204 .
"Please install or enable:\n" . $missingExtText;
207 $web[
'intro'] =
"Installing some PHP extensions is required.";
208 $web[
'longTitle'] =
'Required PHP extensions';
209 $web[
'longHtml'] = <<<HTML
211 You are missing one or more extensions to PHP that
MediaWiki requires to run. Please see the
212 <a href=
"https://www.mediawiki.org/wiki/Manual:Installation_requirements#PHP">PHP
213 installation requirements</a> on
MediaWiki.org.
215 <p>Please install or enable:</p>
229 $protocol = isset( $_SERVER[
'SERVER_PROTOCOL'] ) ? $_SERVER[
'SERVER_PROTOCOL'] :
'HTTP/1.0';
231 header(
"$protocol 500 MediaWiki configuration Error" );
233 header(
'Cache-Control: no-cache' );
246 htmlspecialchars( str_replace(
'//',
'/', $this->scriptPath .
'/' ) .
247 'resources/assets/mediawiki.png' );
249 $introHtml = htmlspecialchars( $introText );
250 $longTitleHtml = htmlspecialchars( $longTitle );
252 header(
'Content-type: text/html; charset=UTF-8' );
254 $finalOutput = <<<HTML
256<html lang=
"en" dir=
"ltr">
258 <meta charset=
"UTF-8" />
259 <title>
MediaWiki {$this->mwVersion}</title>
260 <style media=
"screen">
263 background-color: #fff;
264 font-family: sans-serif;
281 <img src=
"{$encLogo}" alt=
"The MediaWiki logo" />
282 <h1>
MediaWiki {$this->mwVersion}
internal error</h1>
286 <h2>{$longTitleHtml}</h2>
310 if ( $this->format ===
'html' ) {
320 $finalOutput = $cliText;
323 echo
"$finalOutput\n";
337 $phpVersionCheck->setFormat( $format );
338 $phpVersionCheck->setScriptPath( $scriptPath );
339 $phpVersionCheck->checkRequiredPHPVersion();
340 $phpVersionCheck->checkVendorExistence();
341 $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.