MediaWiki  master
PHPVersionCheck Class Reference

Check PHP Version, as well as for composer dependencies in entry points, and display something vaguely comprehensible in the event of a totally unrecoverable error. More...

Public Member Functions

 checkExtensionExistence ()
 Displays an error, if a PHP extension does not exist. More...
 
 checkRequiredPHPVersion ()
 Displays an error, if the installed PHP version does not meet the minimum requirement. More...
 
 checkVendorExistence ()
 Displays an error, if the vendor/autoload.php file could not be found. More...
 
 getIndexErrorOutput ( $introText, $longTitle, $longHtml)
 Returns an error page, which is suitable for output to the end user via a web browser. More...
 
 outputHTMLHeader ()
 Output headers that prevents error pages to be cached. More...
 
 setFormat ( $format)
 Set the format used for errors. More...
 
 setScriptPath ( $scriptPath)
 Set the script path used for images in HTML-formatted errors. More...
 
 triggerError ( $web, $cliText)
 Display something vaguely comprehensible in the event of a totally unrecoverable error. More...
 

Public Attributes

string $format = 'text'
 The format used for errors. More...
 
string[] $functionsExtensionsMapping
 A mapping of PHP functions to PHP extensions. More...
 
string $mwVersion = '1.36'
 The number of the MediaWiki version used. More...
 
 $scriptPath = '/'
 

Detailed Description

Check PHP Version, as well as for composer dependencies in entry points, and display something vaguely comprehensible in the event of a totally unrecoverable error.

Note
Since we can't rely on anything external, the minimum PHP versions and MW current version are hardcoded in this class.
This class uses setter methods instead of a constructor so that it can be compatible with PHP 4, PHP 5 and PHP 7 (without warnings).

Definition at line 35 of file PHPVersionCheck.php.

Member Function Documentation

◆ checkExtensionExistence()

PHPVersionCheck::checkExtensionExistence ( )

Displays an error, if a PHP extension does not exist.

Definition at line 148 of file PHPVersionCheck.php.

References $ext, and triggerError().

◆ checkRequiredPHPVersion()

PHPVersionCheck::checkRequiredPHPVersion ( )

Displays an error, if the installed PHP version does not meet the minimum requirement.

Definition at line 80 of file PHPVersionCheck.php.

References triggerError().

◆ checkVendorExistence()

PHPVersionCheck::checkVendorExistence ( )

Displays an error, if the vendor/autoload.php file could not be found.

Definition at line 119 of file PHPVersionCheck.php.

References triggerError().

◆ getIndexErrorOutput()

PHPVersionCheck::getIndexErrorOutput (   $introText,
  $longTitle,
  $longHtml 
)

Returns an error page, which is suitable for output to the end user via a web browser.

Parameters
string$introText
string$longTitle
string$longHtml
Returns
string

Definition at line 207 of file PHPVersionCheck.php.

Referenced by triggerError().

◆ outputHTMLHeader()

PHPVersionCheck::outputHTMLHeader ( )

Output headers that prevents error pages to be cached.

Definition at line 190 of file PHPVersionCheck.php.

Referenced by triggerError().

◆ setFormat()

PHPVersionCheck::setFormat (   $format)

Set the format used for errors.

Parameters
string$formatOne of "text" or "html"

Definition at line 64 of file PHPVersionCheck.php.

References $format.

◆ setScriptPath()

PHPVersionCheck::setScriptPath (   $scriptPath)

Set the script path used for images in HTML-formatted errors.

Parameters
string$scriptPath

Definition at line 73 of file PHPVersionCheck.php.

References $scriptPath.

◆ triggerError()

PHPVersionCheck::triggerError (   $web,
  $cliText 
)

Display something vaguely comprehensible in the event of a totally unrecoverable error.

Does not assume access to anything; no globals, no autoloader, no database, no localisation. Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php no longer need to be).

This function immediately terminates the PHP process.

Parameters
string[]$web
  • (string) intro: Short error message, displayed on top.
  • (string) longTitle: Title for the longer message.
  • (string) longHtml: The longer message, as raw HTML.
string$cliText

Definition at line 272 of file PHPVersionCheck.php.

References getIndexErrorOutput(), and outputHTMLHeader().

Referenced by checkExtensionExistence(), checkRequiredPHPVersion(), and checkVendorExistence().

Member Data Documentation

◆ $format

string PHPVersionCheck::$format = 'text'

The format used for errors.

One of "text" or "html"

Definition at line 52 of file PHPVersionCheck.php.

Referenced by setFormat().

◆ $functionsExtensionsMapping

string [] PHPVersionCheck::$functionsExtensionsMapping
Initial value:
= array(
'mb_substr' => 'mbstring',
'xml_parser_create' => 'xml',
'ctype_digit' => 'ctype',
'json_decode' => 'json',
'iconv' => 'iconv',
'mime_content_type' => 'fileinfo',
)

A mapping of PHP functions to PHP extensions.

Definition at line 40 of file PHPVersionCheck.php.

◆ $mwVersion

string PHPVersionCheck::$mwVersion = '1.36'

The number of the MediaWiki version used.

Definition at line 37 of file PHPVersionCheck.php.

◆ $scriptPath

string PHPVersionCheck::$scriptPath = '/'

Definition at line 57 of file PHPVersionCheck.php.

Referenced by setScriptPath().


The documentation for this class was generated from the following file: