Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-35207 Fix 1.9 > 2.x upgrade of workshop submission attachments

Attachments of submission with non-linear ids in 1.9 database were not
upgraded correctly due to old id and new id mismatch. Credit goes to
Juan Segarra Montesinos for spotting the problem and suggesting a patch.
  • Loading branch information...
commit dd7946d99742e776f3db2f7637cf34bd9d1a4352 1 parent 4db3699
@mudrd8mz mudrd8mz authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 mod/workshop/db/upgrade.php
View
7 mod/workshop/db/upgrade.php
@@ -132,13 +132,14 @@ function xmldb_workshop_upgrade($oldversion) {
// $filearea = "$workshop->course/$CFG->moddata/workshop/$submission->id";
$fs = get_file_storage();
$from = 'FROM {workshop_submissions} s
+ JOIN {workshop_submissions_old} o ON (o.newid = s.id)
JOIN {workshop} w ON (w.id = s.workshopid)
JOIN {modules} m ON (m.name = :modulename)
JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = w.id)
WHERE s.attachment <> 1';
$params = array('modulename' => 'workshop');
$count = $DB->count_records_sql('SELECT COUNT(s.id) ' . $from, $params);
- $rs = $DB->get_recordset_sql('SELECT s.id, s.authorid, s.workshopid, cm.course, cm.id AS cmid ' .
+ $rs = $DB->get_recordset_sql('SELECT s.id, o.id AS oldid, s.authorid, s.workshopid, cm.course, cm.id AS cmid ' .
$from . ' ORDER BY cm.course, w.id', $params);
$pbar = new progress_bar('migrateworkshopsubmissions', 500, true);
$i = 0;
@@ -147,7 +148,7 @@ function xmldb_workshop_upgrade($oldversion) {
upgrade_set_timeout(60); // set up timeout, may also abort execution
$pbar->update($i, $count, "Migrating workshop submissions - $i/$count");
- $filedir = "$CFG->dataroot/$submission->course/$CFG->moddata/workshop/$submission->id";
+ $filedir = "$CFG->dataroot/$submission->course/$CFG->moddata/workshop/$submission->oldid";
if ($files = get_directory_list($filedir, '', false)) {
$context = get_context_instance(CONTEXT_MODULE, $submission->cmid);
foreach ($files as $filename) {
@@ -178,7 +179,7 @@ function xmldb_workshop_upgrade($oldversion) {
}
}
// remove dirs if empty
- @rmdir("$CFG->dataroot/$submission->course/$CFG->moddata/workshop/$submission->id");
+ @rmdir("$CFG->dataroot/$submission->course/$CFG->moddata/workshop/$submission->oldid");
@rmdir("$CFG->dataroot/$submission->course/$CFG->moddata/workshop");
@rmdir("$CFG->dataroot/$submission->course/$CFG->moddata");
@rmdir("$CFG->dataroot/$submission->course");

0 comments on commit dd7946d

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