mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-20438 New moodle_major_version() function
We will need to know our major version to fetch the relevant data from remote servers. This patch also fixes yet another place where the version used to be hard-coded.
This commit is contained in:
parent
2b135b05d8
commit
9c26cf7060
@ -585,14 +585,13 @@ class lang_installer {
|
||||
/**
|
||||
* Prepare the installer
|
||||
*
|
||||
* @todo Moodle major version is hardcoded here, should be obtained from version.php or so
|
||||
* @param string|array $langcode a code of the language to install
|
||||
*/
|
||||
public function __construct($langcode = '') {
|
||||
global $CFG;
|
||||
|
||||
$this->set_queue($langcode);
|
||||
$this->version = '2.2';
|
||||
$this->version = moodle_major_version(true);
|
||||
|
||||
if (!empty($CFG->langotherroot) and $CFG->langotherroot !== $CFG->dataroot . '/lang') {
|
||||
debugging('The in-built language pack installer does not support alternative location ' .
|
||||
|
@ -8686,6 +8686,42 @@ function moodle_needs_upgrading() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the major version of this site
|
||||
*
|
||||
* Moodle version numbers consist of three numbers separated by a dot, for
|
||||
* example 1.9.11 or 2.0.2. The first two numbers, like 1.9 or 2.0, represent so
|
||||
* called major version. This function extracts the major version from either
|
||||
* $CFG->release (default) or eventually from the $release variable defined in
|
||||
* the main version.php.
|
||||
*
|
||||
* @param bool $fromdisk should the version if source code files be used
|
||||
* @return string|false the major version like '2.3', false if could not be determined
|
||||
*/
|
||||
function moodle_major_version($fromdisk = false) {
|
||||
global $CFG;
|
||||
|
||||
if ($fromdisk) {
|
||||
$release = null;
|
||||
require($CFG->dirroot.'/version.php');
|
||||
if (empty($release)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (empty($CFG->release)) {
|
||||
return false;
|
||||
}
|
||||
$release = $CFG->release;
|
||||
}
|
||||
|
||||
if (preg_match('/^[0-9]+\.[0-9]+/', $release, $matches)) {
|
||||
return $matches[0];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets maximum expected time needed for upgrade task.
|
||||
* Please always make sure that upgrade will not run longer!
|
||||
|
Loading…
x
Reference in New Issue
Block a user