X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPHPVersionCheck.php;h=5a440c4e2cf1f463dd7c31048935a6164eccf820;hb=4d25eb68a57363dcb9e9be981d497cccf50a8c0b;hp=c8e29c1920339a869756f3457a7214d6b234111f;hpb=3345b70b63ec828a58796b7f39a063c703f50339;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/PHPVersionCheck.php b/includes/PHPVersionCheck.php index c8e29c1920..5a440c4e2c 100644 --- a/includes/PHPVersionCheck.php +++ b/includes/PHPVersionCheck.php @@ -3,10 +3,6 @@ // @codingStandardsIgnoreFile Generic.Files.LineLength // @codingStandardsIgnoreFile MediaWiki.Usage.DirUsage.FunctionFound /** - * 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. - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -24,11 +20,16 @@ * * @file */ + +/** + * 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. + * @class + */ class PHPVersionCheck { /* @var string The number of the MediaWiki version used */ var $mwVersion = '1.30'; - /* @var string The minimum php version for MediaWiki to run */ - var $minimumVersionPHP = '5.5.9'; var $functionsExtensionsMapping = array( 'mb_substr' => 'mbstring', 'utf8_encode' => 'xml', @@ -63,10 +64,41 @@ class PHPVersionCheck { /** * Returns the version of the installed php implementation. * - * @return string + * @param string $impl By default, the function returns the info of the currently installed PHP + * implementation. Using this parameter the caller can decide, what version info will be + * returned. Valid values: HHVM, PHP + * @return array An array of information about the php implementation, containing: + * - 'version': The version of the php implementation (specific to the implementation, not + * the version of the implemented php version) + * - 'implementation': The name of the implementation used + * - 'vendor': The development group, vendor or developer of the implementation. + * - 'upstreamSupported': The minimum version of the implementation supported by the named vendor. + * - 'minSupported': The minimum version supported by MediWiki + * - 'upgradeURL': The URL to the website of the implementation that contains + * upgrade/installation instructions. */ - function getPHPImplVersion() { - return PHP_VERSION; + function getPHPInfo( $impl = false ) { + if ( + ( defined( 'HHVM_VERSION' ) && $impl !== 'PHP' ) || + $impl === 'HHVM' + ) { + return array( + 'implementation' => 'HHVM', + 'version' => defined( 'HHVM_VERSION' ) ? HHVM_VERSION : 'undefined', + 'vendor' => 'Facebook', + 'upstreamSupported' => '3.6.5', + 'minSupported' => '3.6.5', + 'upgradeURL' => 'https://docs.hhvm.com/hhvm/installation/introduction', + ); + } + return array( + 'implementation' => 'PHP', + 'version' => PHP_VERSION, + 'vendor' => 'the PHP Group', + 'upstreamSupported' => '5.5.0', + 'minSupported' => '5.5.9', + 'upgradeURL' => 'http://www.php.net/downloads.php', + ); } /** @@ -75,31 +107,44 @@ class PHPVersionCheck { * @return $this */ function checkRequiredPHPVersion() { + $phpInfo = $this->getPHPInfo(); + $minimumVersion = $phpInfo['minSupported']; + $otherInfo = $this->getPHPInfo( $phpInfo['implementation'] === 'HHVM' ? 'PHP' : 'HHVM' ); if ( !function_exists( 'version_compare' ) - || version_compare( $this->getPHPImplVersion(), $this->minimumVersionPHP ) < 0 + || version_compare( $phpInfo['version'], $minimumVersion ) < 0 ) { - $shortText = "MediaWiki $this->mwVersion requires at least PHP version" - . " $this->minimumVersionPHP, you are using PHP {$this->getPHPImplVersion()}."; + $shortText = "MediaWiki $this->mwVersion requires at least {$phpInfo['implementation']}" + . " version $minimumVersion or {$otherInfo['implementation']} version " + . "{$otherInfo['minSupported']}, you are using {$phpInfo['implementation']} " + . "{$phpInfo['version']}."; - $longText = "Error: You might be using on older PHP version. \n" - . "MediaWiki $this->mwVersion needs PHP $this->minimumVersionPHP or higher.\n\n" - . "Check if you have a newer php executable with a different name, " - . "such as php5.\n\n"; + $longText = "Error: You might be using an older {$phpInfo['implementation']} version. \n" + . "MediaWiki $this->mwVersion needs {$phpInfo['implementation']}" + . " $minimumVersion or higher or {$otherInfo['implementation']} version " + . "{$otherInfo['minSupported']}.\n\nCheck if you have a" + . " newer php executable with a different name, such as php5.\n\n"; $longHtml = <<upgrading your copy of PHP. - PHP versions less than 5.5.0 are no longer supported by the PHP Group and will not receive + Please consider upgrading your copy of + {$phpInfo['implementation']}. + {$phpInfo['implementation']} versions less than {$phpInfo['upstreamSupported']} are no + longer supported by {$phpInfo['vendor']} and will not receive security or bugfix updates.

- If for some reason you are unable to upgrade your PHP version, you will need to - download an older version - of MediaWiki from our website. See our - compatibility page - for details of which versions are compatible with prior versions of PHP. + If for some reason you are unable to upgrade your {$phpInfo['implementation']} version, + you will need to download an + older version of MediaWiki from our website. + See ourcompatibility page + for details of which versions are compatible with prior versions of {$phpInfo['implementation']}. HTML; - $this->triggerError( 'Supported PHP versions', $shortText, $longText, $longHtml ); + $this->triggerError( + "Supported {$phpInfo['implementation']} versions", + $shortText, + $longText, + $longHtml + ); } }