Skip to content
Browse files

Merge branch 'MDL-28180_21' of git://github.com/stronk7/moodle into M…

…OODLE_21_STABLE
  • Loading branch information...
2 parents 494b8a8 + e86f88a commit 1ac4f0edbcf1cea05f22d4a85cc84e350f96f86f Sam Hemelryk committed Dec 12, 2011
View
8 backup/controller/backup_controller.class.php
@@ -293,6 +293,14 @@ public function execute_plan() {
// Basic/initial prevention against time/memory limits
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
+ // If this is not a course backup, inform the plan we are not
+ // including all the activities for sure. This will affect any
+ // task/step executed conditionally to stop including information
+ // for section and activity backup. MDL-28180.
+ if ($this->get_type() !== backup::TYPE_1COURSE) {
+ $this->log('notifying plan about excluded activities by type', backup::LOG_DEBUG);
+ $this->plan->set_excluding_activities();
+ }
return $this->plan->execute();
}
View
8 backup/controller/restore_controller.class.php
@@ -299,6 +299,14 @@ public function execute_plan() {
// Basic/initial prevention against time/memory limits
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
+ // If this is not a course restore, inform the plan we are not
+ // including all the activities for sure. This will affect any
+ // task/step executed conditionally to stop processing information
+ // for section and activity restore. MDL-28180.
+ if ($this->get_type() !== backup::TYPE_1COURSE) {
+ $this->log('notifying plan about excluded activities by type', backup::LOG_DEBUG);
+ $this->plan->set_excluding_activities();
+ }
return $this->plan->execute();
}
View
21 backup/moodle2/restore_stepslib.php
@@ -1751,15 +1751,20 @@ public function process_course_completion_aggr_methd($data) {
$data->course = $this->get_courseid();
- $params = array(
- 'course' => $data->course,
- 'criteriatype' => $data->criteriatype,
- 'method' => $data->method,
- 'value' => $data->value,
- );
- $DB->insert_record('course_completion_aggr_methd', $params);
+ // Only create the course_completion_aggr_methd records if
+ // the target course has not them defined. MDL-28180
+ if (!$DB->record_exists('course_completion_aggr_methd', array(
+ 'course' => $data->course,
+ 'criteriatype' => $data->criteriatype))) {
+ $params = array(
+ 'course' => $data->course,
+ 'criteriatype' => $data->criteriatype,
+ 'method' => $data->method,
+ 'value' => $data->value,
+ );
+ $DB->insert_record('course_completion_aggr_methd', $params);
+ }
}
-
}
View
1 backup/util/plan/backup_plan.class.php
@@ -44,6 +44,7 @@ public function __construct($controller) {
}
$this->controller = $controller;
$this->basepath = $CFG->dataroot . '/temp/backup/' . $controller->get_backupid();
+ $this->excludingdactivities = false;
parent::__construct('backup_plan');
}
View
28 lib/db/upgrade.php
@@ -6696,6 +6696,34 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011070102.08);
}
+ if ($oldversion < 2011070103.04) {
+
+ upgrade_set_timeout(60*20); // This may take a while
+ // MDL-28180. Some missing restrictions in certain backup & restore operations
+ // were causing incorrect duplicates in the course_completion_aggr_methd table.
+ // This upgrade step takes rid of them.
+ $sql = 'SELECT course, criteriatype, MIN(id) AS minid
+ FROM {course_completion_aggr_methd}
+ GROUP BY course, criteriatype
+ HAVING COUNT(*) > 1';
+ $duprs = $DB->get_recordset_sql($sql);
+ foreach ($duprs as $duprec) {
+ // We need to handle NULLs in criteriatype diferently
+ if (is_null($duprec->criteriatype)) {
+ $where = 'course = ? AND criteriatype IS NULL AND id > ?';
+ $params = array($duprec->course, $duprec->minid);
+ } else {
+ $where = 'course = ? AND criteriatype = ? AND id > ?';
+ $params = array($duprec->course, $duprec->criteriatype, $duprec->minid);
+ }
+ $DB->delete_records_select('course_completion_aggr_methd', $where, $params);
+ }
+ $duprs->close();
+
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2011070103.04);
+ }
+
return true;
}
View
2 version.php
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2011070103.03; // 20110701 = branching date YYYYMMDD - do not modify!
+$version = 2011070103.04; // 20110701 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

0 comments on commit 1ac4f0e

Please sign in to comment.
Something went wrong with that request. Please try again.