Paladox has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/354671 )
Change subject: Add HHVM version check ...................................................................... Add HHVM version check HHVM brings it's own version number, so relying on the PHP version string in the PHP_VERSION const on an hhvm server maybe does not increase in different versions of hhvm. Therefore, this change implements a hhvm server version check, if MediaWiki runs on an hhvm server, instead of checking the php version. Bug: T123436 Change-Id: I91b0a4e1eded61d3ba63ecbd14cdc85c57295892 --- M includes/PHPVersionCheck.php 1 file changed, 69 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/71/354671/1 diff --git a/includes/PHPVersionCheck.php b/includes/PHPVersionCheck.php index c56931e..a6c625c 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.29'; - /* @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 @@ /** * 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 @@ * @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 = <<<HTML - Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>. - PHP versions less than 5.5.0 are no longer supported by the PHP Group and will not receive + Please consider <a href="{$phpInfo['upgradeURL']}">upgrading your copy of + {$phpInfo['implementation']}</a>. + {$phpInfo['implementation']} versions less than {$phpInfo['upstreamSupported']} are no + longer supported by {$phpInfo['vendor']} and will not receive security or bugfix updates. </p> <p> - If for some reason you are unable to upgrade your PHP version, you will need to - <a href="https://www.mediawiki.org/wiki/Download">download</a> an older version - of MediaWiki from our website. See our - <a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a> - 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 <a href="https://www.mediawiki.org/wiki/Download">download</a> an + older version of MediaWiki from our website. + See our<a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a> + 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 + ); } } -- To view, visit https://gerrit.wikimedia.org/r/354671 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I91b0a4e1eded61d3ba63ecbd14cdc85c57295892 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: REL1_29 Gerrit-Owner: Paladox <thomasmulhall...@yahoo.com> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits