From: Florian Schmidt
Date: Tue, 13 Sep 2016 16:17:11 +0000 (+0200)
Subject: Add HHVM version check
X-Git-Tag: 1.31.0-rc.0~3210^2
X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=639e9ff3f24ad5d802289e193fe69bc53651391a;p=lhc%2Fweb%2Fwiklou.git
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
---
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
+ );
}
}