Skip to content

Commit

Permalink
Merge branch 'MDL-69475' of https://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Aug 19, 2020
2 parents d8d05f0 + b7100ae commit 6786600
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
17 changes: 8 additions & 9 deletions backup/moodle2/restore_stepslib.php
Expand Up @@ -122,7 +122,7 @@ protected function execute_condition() {
}

// Identify the backup we're dealing with.
$backuprelease = floatval($this->get_task()->get_info()->backup_release); // The major version: 2.9, 3.0, ...
$backuprelease = $this->get_task()->get_info()->backup_release; // The major version: 2.9, 3.0, 3.10...
$backupbuild = 0;
preg_match('/(\d{8})/', $this->get_task()->get_info()->moodle_release, $matches);
if (!empty($matches[1])) {
Expand All @@ -132,7 +132,7 @@ protected function execute_condition() {
// On older versions the freeze value has to be converted.
// We do this from here as it is happening right before the file is read.
// This only targets the backup files that can contain the legacy freeze.
if ($backupbuild > 20150618 && ($backuprelease < 3.0 || $backupbuild < 20160527)) {
if ($backupbuild > 20150618 && (version_compare($backuprelease, '3.0', '<') || $backupbuild < 20160527)) {
$this->rewrite_step_backup_file_for_legacy_freeze($fullpath);
}

Expand Down Expand Up @@ -505,8 +505,7 @@ protected function gradebook_calculation_freeze() {
$gradebookcalculationsfreeze = get_config('core', 'gradebook_calculations_freeze_' . $this->get_courseid());
preg_match('/(\d{8})/', $this->get_task()->get_info()->moodle_release, $matches);
$backupbuild = (int)$matches[1];
// The function floatval will return a float even if there is text mixed with the release number.
$backuprelease = floatval($this->get_task()->get_info()->backup_release);
$backuprelease = $this->get_task()->get_info()->backup_release; // The major version: 2.9, 3.0, 3.10...

// Extra credits need adjustments only for backups made between 2.8 release (20141110) and the fix release (20150619).
if (!$gradebookcalculationsfreeze && $backupbuild >= 20141110 && $backupbuild < 20150619) {
Expand All @@ -521,7 +520,7 @@ protected function gradebook_calculation_freeze() {
// Courses from before 3.1 (20160518) may have a letter boundary problem and should be checked for this issue.
// Backups from before and including 2.9 could have a build number that is greater than 20160518 and should
// be checked for this problem.
if (!$gradebookcalculationsfreeze && ($backupbuild < 20160518 || $backuprelease <= 2.9)) {
if (!$gradebookcalculationsfreeze && ($backupbuild < 20160518 || version_compare($backuprelease, '2.9', '<='))) {
require_once($CFG->libdir . '/db/upgradelib.php');
upgrade_course_letter_boundary($this->get_courseid());
}
Expand Down Expand Up @@ -4631,11 +4630,11 @@ protected function process_question_category($data) {

// Before 3.5, question categories could be created at top level.
// From 3.5 onwards, all question categories should be a child of a special category called the "top" category.
$backuprelease = floatval($this->get_task()->get_info()->backup_release);
$backuprelease = $this->get_task()->get_info()->backup_release; // The major version: 2.9, 3.0, 3.10...
preg_match('/(\d{8})/', $this->get_task()->get_info()->moodle_release, $matches);
$backupbuild = (int)$matches[1];
$before35 = false;
if ($backuprelease < 3.5 || $backupbuild < 20180205) {
if (version_compare($backuprelease, '3.5', '<') || $backupbuild < 20180205) {
$before35 = true;
}
if (empty($mapping->info->parent) && $before35) {
Expand Down Expand Up @@ -4892,11 +4891,11 @@ class restore_move_module_questions_categories extends restore_execution_step {
protected function define_execution() {
global $DB;

$backuprelease = floatval($this->task->get_info()->backup_release);
$backuprelease = $this->task->get_info()->backup_release; // The major version: 2.9, 3.0, 3.10...
preg_match('/(\d{8})/', $this->task->get_info()->moodle_release, $matches);
$backupbuild = (int)$matches[1];
$after35 = false;
if ($backuprelease >= 3.5 && $backupbuild > 20180205) {
if (version_compare($backuprelease, '3.5', '>=') && $backupbuild > 20180205) {
$after35 = true;
}

Expand Down
4 changes: 2 additions & 2 deletions backup/util/dbops/restore_dbops.class.php
Expand Up @@ -581,11 +581,11 @@ public static function prechek_precheck_qbanks_by_level($restoreid, $courseid, $
$rc = restore_controller_dbops::load_controller($restoreid);
$restoreinfo = $rc->get_info();
$rc->destroy(); // Always need to destroy.
$backuprelease = floatval($restoreinfo->backup_release);
$backuprelease = $restoreinfo->backup_release; // The major version: 2.9, 3.0, 3.10...
preg_match('/(\d{8})/', $restoreinfo->moodle_release, $matches);
$backupbuild = (int)$matches[1];
$after35 = false;
if ($backuprelease >= 3.5 && $backupbuild > 20180205) {
if (version_compare($backuprelease, '3.5', '>=') && $backupbuild > 20180205) {
$after35 = true;
}

Expand Down
Expand Up @@ -48,8 +48,8 @@ class restore_format_topics_plugin extends restore_format_plugin {
*/
protected function need_restore_numsections() {
$backupinfo = $this->step->get_task()->get_info();
$backuprelease = $backupinfo->backup_release;
return version_compare($backuprelease, '3.3', 'lt');
$backuprelease = $backupinfo->backup_release; // The major version: 2.9, 3.0, 3.10...
return version_compare($backuprelease, '3.3', '<');
}

/**
Expand Down
Expand Up @@ -48,8 +48,8 @@ class restore_format_weeks_plugin extends restore_format_plugin {
*/
protected function is_pre_33_backup() {
$backupinfo = $this->step->get_task()->get_info();
$backuprelease = $backupinfo->backup_release;
return version_compare($backuprelease, '3.3', 'lt');
$backuprelease = $backupinfo->backup_release; // The major version: 2.9, 3.0, 3.10...
return version_compare($backuprelease, '3.3', '<');
}

/**
Expand Down

0 comments on commit 6786600

Please sign in to comment.