Permalink
Browse files

Merge branch 'w07_MDL-26352_20_metacourse' of git://github.com/skodak…

…/moodle
  • Loading branch information...
2 parents 798e6fc + d21feff commit c0d0dd4a5a4da3dba3457530907ee5b89dc5910a @stronk7 stronk7 committed Feb 13, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/db/upgrade.php
View
8 lib/db/upgrade.php
@@ -4091,10 +4091,12 @@ function xmldb_main_upgrade($oldversion) {
}
if ($oldversion < 2010061900.10) {
- // migrate existing setup of meta courses
+ // migrate existing setup of meta courses, ignore records referencing invalid courses
$sql = "INSERT INTO {enrol} (enrol, status, courseid, sortorder, customint1)
- SELECT 'meta', 0, parent_course, 5, child_course
- FROM {course_meta}";
+ SELECT 'meta', 0, cm.parent_course, 5, cm.child_course
+ FROM {course_meta} cm
+ JOIN {course} p ON p.id = cm.parent_course
+ JOIN {course} c ON c.id = cm.child_course";
$DB->execute($sql);
upgrade_main_savepoint(true, 2010061900.10);

0 comments on commit c0d0dd4

Please sign in to comment.