X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPHPVersionCheck.php;h=018c6f83dcb5214ca2b9313a9d9b352a4d3e9d2b;hb=f47d1eee0e17769f40360e4052a254db99fc35d5;hp=ab8aada836c2733c922505117b958451ff4c1b8f;hpb=045357380dc28826436884ce39ede285f2ac3ce2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/PHPVersionCheck.php b/includes/PHPVersionCheck.php index ab8aada836..018c6f83dc 100644 --- a/includes/PHPVersionCheck.php +++ b/includes/PHPVersionCheck.php @@ -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 ); +}