X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FPHPVersionCheck.php;h=018c6f83dcb5214ca2b9313a9d9b352a4d3e9d2b;hb=d3a51a690c977efe2d97f911f279a4ac791a8e83;hp=1eafcfa5b806343020b3edff8e15aad747cb59f8;hpb=42fe7284cd78988f745a2f0f6a33e4921699b8dc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/PHPVersionCheck.php b/includes/PHPVersionCheck.php index 1eafcfa5b8..018c6f83dc 100644 --- a/includes/PHPVersionCheck.php +++ b/includes/PHPVersionCheck.php @@ -30,7 +30,7 @@ * version are hardcoded here */ function wfEntryPointCheck( $entryPoint ) { - $mwVersion = '1.27'; + $mwVersion = '1.28'; $minimumVersionPHP = '5.5.9'; $phpVersion = PHP_VERSION; @@ -45,6 +45,29 @@ function wfEntryPointCheck( $entryPoint ) { // @codingStandardsIgnoreEnd wfMissingVendorError( $entryPoint, $mwVersion ); } + + // List of functions and their associated PHP extension to check for + // @codingStandardsIgnoreStart Generic.Arrays.DisallowLongArraySyntax + $extensions = array( + 'mb_substr' => 'mbstring', + 'utf8_encode' => 'xml', + 'ctype_digit' => 'ctype', + 'json_decode' => 'json', + 'iconv' => 'iconv', + ); + // List of extensions we're missing + $missingExtensions = array(); + // @codingStandardsIgnoreEnd + + foreach ( $extensions as $function => $extension ) { + if ( !function_exists( $function ) ) { + $missingExtensions[] = $extension; + } + } + + if ( $missingExtensions ) { + wfMissingExtensions( $entryPoint, $mwVersion, $missingExtensions ); + } } /** @@ -107,7 +130,7 @@ function wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $long padding: 2em; text-align: center; } - p, img, h1, h2 { + p, img, h1, h2, ul { text-align: left; margin: 0.5em 0 1em; } @@ -201,3 +224,38 @@ HTML; wfGenericError( $type, $mwVersion, 'External dependencies', $shortText, $longText, $longHtml ); } + +/** + * Display an error for a PHP extension not existing. + * + * @param string $type See wfGenericError + * @param string $mwVersion See wfGenericError + * @param array $missingExts The extensions we're missing + */ +function wfMissingExtensions( $type, $mwVersion, $missingExts ) { + $shortText = "Installing some PHP extensions is required."; + + $missingExtText = ''; + $missingExtHtml = ''; + $baseUrl = 'https://secure.php.net'; + foreach ( $missingExts as $ext ) { + $missingExtText .= " * $ext <$baseUrl/$ext>\n"; + $missingExtHtml .= "
  • $ext " + . "(more information)
  • "; + } + + $cliText = "Error: Missing one or more required components of PHP.\n" + . "You are missing a required extension to PHP that MediaWiki needs.\n" + . "Please install:\n" . $missingExtText; + + $longHtml = << + $missingExtHtml + +HTML; + + wfGenericError( $type, $mwVersion, 'Required components', $shortText, + $cliText, $longHtml ); +}