mirror of
https://github.com/moodle/moodle.git
synced 2025-04-18 23:15:38 +02:00
MDL-50624 environment: add PHP7 as unsupported version
Added PHP7 as an unsupported version for Moodle 2.8 and 2.9 in the environment checks
This commit is contained in:
parent
d84625438e
commit
19452dc4be
@ -1150,6 +1150,7 @@
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
@ -1273,6 +1274,7 @@
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
|
@ -1072,6 +1072,7 @@ $string['unsettheme'] = 'Unset theme';
|
||||
$string['unsupported'] = 'Unsupported';
|
||||
$string['unsupporteddbstorageengine'] = 'The database storage engine being used is no longer supported.';
|
||||
$string['unsupporteddbtablerowformat'] = 'Your database has tables using Antelope as the file format. You are recommended to convert the tables to the Barracuda file format. See the documentation <a href="https://docs.moodle.org/en/cli">Administration via command line</a> for details of a tool for converting InnoDB tables to Barracuda.';
|
||||
$string['unsupportedphpversion7'] = 'PHP version 7 is not supported.';
|
||||
$string['unsuspenduser'] = 'Activate user account';
|
||||
$string['updateaccounts'] = 'Update existing accounts';
|
||||
$string['updatecomponent'] = 'Update component';
|
||||
|
@ -1538,3 +1538,37 @@ function process_environment_result($element, &$result) {
|
||||
/// Process restrict, modifying $result if needed.
|
||||
process_environment_restrict($element, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current PHP version is greater than or equal to
|
||||
* PHP version 7.
|
||||
*
|
||||
* @param object $result an environment_results instance
|
||||
* @return bool result of version check
|
||||
*/
|
||||
function restrict_php_version_7(&$result) {
|
||||
return restrict_php_version($result, '7');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current PHP version is greater than or equal to an
|
||||
* unsupported version.
|
||||
*
|
||||
* @param object $result an environment_results instance
|
||||
* @param string $version the version of PHP that can't be used
|
||||
* @return bool result of version check
|
||||
*/
|
||||
function restrict_php_version(&$result, $version) {
|
||||
|
||||
// Get the current PHP version.
|
||||
$currentversion = normalize_version(phpversion());
|
||||
|
||||
// Confirm we're using a supported PHP version.
|
||||
if (version_compare($currentversion, $version, '<')) {
|
||||
// Everything is ok, the restriction doesn't apply.
|
||||
return false;
|
||||
} else {
|
||||
// We're using an unsupported PHP version, apply restriction.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -128,4 +128,69 @@ END;
|
||||
$this->assertFalse(environment_verify_plugin('mod_someother', $plugin1['PLUGIN']));
|
||||
$this->assertFalse(environment_verify_plugin('mod_someother', $plugin2['PLUGIN']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the restrict_php_version() function returns true if the current
|
||||
* PHP version is greater than the restricted version
|
||||
*/
|
||||
public function test_restrict_php_version_greater_than_restricted_version() {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
|
||||
$result = new environment_results('php');
|
||||
$delimiter = '.';
|
||||
// Get the current PHP version.
|
||||
$currentversion = explode($delimiter, normalize_version(phpversion()));
|
||||
// Lets drop back one major version to ensure we trip the restriction.
|
||||
$currentversion[0]--;
|
||||
$restrictedversion = implode($delimiter, $currentversion);
|
||||
|
||||
// Make sure the status is true before the test to see it flip to false.
|
||||
$result->setStatus(true);
|
||||
|
||||
$this->assertTrue(restrict_php_version($result, $restrictedversion),
|
||||
'restrict_php_version returns true if the current version exceeds the restricted version');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the restrict_php_version() function returns true if the current
|
||||
* PHP version is equal to the restricted version
|
||||
*/
|
||||
public function test_restrict_php_version_equal_to_restricted_version() {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
|
||||
$result = new environment_results('php');
|
||||
// Get the current PHP version.
|
||||
$currentversion = normalize_version(phpversion());
|
||||
|
||||
// Make sure the status is true before the test to see it flip to false.
|
||||
$result->setStatus(true);
|
||||
|
||||
$this->assertTrue(restrict_php_version($result, $currentversion),
|
||||
'restrict_php_version returns true if the current version is equal to the restricted version');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the restrict_php_version() function returns false if the current
|
||||
* PHP version is less than the restricted version
|
||||
*/
|
||||
public function test_restrict_php_version_less_than_restricted_version() {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
|
||||
$result = new environment_results('php');
|
||||
$delimiter = '.';
|
||||
// Get the current PHP version.
|
||||
$currentversion = explode($delimiter, normalize_version(phpversion()));
|
||||
// Lets increase the major version to ensure don't trip the restriction.
|
||||
$currentversion[0]++;
|
||||
$restrictedversion = implode($delimiter, $currentversion);
|
||||
|
||||
// Make sure the status is true before the test to see it flip to false.
|
||||
$result->setStatus(true);
|
||||
|
||||
$this->assertFalse(restrict_php_version($result, $restrictedversion),
|
||||
'restrict_php_version returns false if the current version is less than the restricted version');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user