MDL-55777 installation: Check libcurl version on install

This commit is contained in:
Ankit Agarwal
2016-11-10 10:24:09 +05:30
parent 216b71f03e
commit 86c22b202d
4 changed files with 72 additions and 0 deletions
+25
View File
@@ -1145,6 +1145,11 @@
<ON_CHECK message="unsupporteddbtablerowformat" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
<FEEDBACK>
<ON_CHECK message="libcurlwarning" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="2.8" requires="2.2">
@@ -1418,6 +1423,11 @@
<ON_CHECK message="unsupporteddbtablerowformat" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
<FEEDBACK>
<ON_CHECK message="libcurlwarning" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="3.0" requires="2.2">
@@ -1556,6 +1566,11 @@
<ON_CHECK message="unsupporteddbtablerowformat" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
<FEEDBACK>
<ON_CHECK message="libcurlwarning" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="3.1" requires="2.7">
@@ -1696,6 +1711,11 @@
<ON_CHECK message="unsupporteddbtablerowformat" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
<FEEDBACK>
<ON_CHECK message="libcurlwarning" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="3.2" requires="2.7">
@@ -1841,6 +1861,11 @@
<ON_CHECK message="unoconvwarning" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
<FEEDBACK>
<ON_CHECK message="libcurlwarning" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>
+1
View File
@@ -612,6 +612,7 @@ $string['legacyfilesaddallowed'] = 'Allow adding to legacy course files';
$string['legacyfilesaddallowed_help'] = 'If a course has legacy course files, allow new files and folders to be added to it.';
$string['legacyfilesinnewcourses'] = 'Legacy course files in new courses';
$string['legacyfilesinnewcourses_help'] = 'By default, legacy course files areas are available in upgraded courses only. Please note that some features such as activity backup and restore are not compatible with this setting.';
$string['libcurlwarning'] = 'Libcurl with CURLOPT_PROTOCOL support has not been detected. It is recommended to have an up to date libcurl installation for security reasons.';
$string['licensesettings'] = 'Licence settings';
$string['linkadmincategories'] = 'Link admin categories';
$string['linkadmincategories_help'] = 'If enabled admin setting categories will be displayed as links in the navigation and will lead to the admin category pages.';
+17
View File
@@ -741,4 +741,21 @@ class core_upgradelib_testcase extends advanced_testcase {
$this->assertEquals($gradecategoryitem->grademax, $grade->rawgrademax);
$this->assertEquals($gradecategoryitem->grademin, $grade->rawgrademin);
}
/**
* Test libcurl custom check api.
*/
public function test_check_libcurl_version() {
$supportedversion = 0x071304;
$curlinfo = curl_version();
$currentversion = $curlinfo['version_number'];
$result = new environment_results("custom_checks");
if ($currentversion < $supportedversion) {
$this->assertFalse(check_libcurl_version($result)->getStatus());
} else {
$this->assertNull(check_libcurl_version($result));
}
}
}
+29
View File
@@ -2331,3 +2331,32 @@ function upgrade_minmaxgrade() {
}
$rs->close();
}
/**
* Check if recommended version of libcurl is installed or not.
*
* @param environment_results $result object to update, if relevant.
* @return environment_results|null updated results or null.
*/
function check_libcurl_version(environment_results $result) {
// Supported version and version number.
$supportedversion = 0x071304;
$supportedversionstring = "7.19.4";
// Installed version.
$curlinfo = curl_version();
$currentversion = $curlinfo['version_number'];
if ($currentversion < $supportedversion) {
// Test fail.
// Set info, we want to let user know how to resolve the problem.
$result->setInfo('Libcurl version check');
$result->setNeededVersion($supportedversionstring);
$result->setCurrentVersion($curlinfo['version']);
$result->setStatus(false);
return $result;
}
return null;
}