Permalink
Browse files

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

…OODLE_20_STABLE
  • Loading branch information...
2 parents 9a45c1e + 54c5b28 commit 1114c49f51f052e21646c398891717a3aa37ba59 Sam Hemelryk committed Dec 12, 2011
@@ -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();
}
@@ -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();
}
@@ -1741,15 +1741,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);
+ }
}
-
}
@@ -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
@@ -6177,6 +6177,34 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011033005.07);
}
+ if ($oldversion < 2011033006.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, 2011033006.04);
+ }
+
return true;
}
View
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2011033006.03; // 20110330 = branching date YYYYMMDD - do not modify!
+$version = 2011033006.04; // 20110330 = branching date YYYYMMDD - do not modify!
// RR = release version - do not change in weeklies
// .XX = incremental changes

0 comments on commit 1114c49

Please sign in to comment.