--- base/backup/restorelib.php 2009-06-09 15:56:58.000000000 -0700 +++ working_copy/backup/restorelib.php 2009-06-26 12:01:04.000000000 -0700 @@ -3520,6 +3520,9 @@ //This function creates all the groupings function restore_create_groupings($restore,$xml_file) { + // MOD -- Needed for a fix down below + global $CFG; + // End MOD //Check it exists if (!file_exists($xml_file)) { @@ -3550,7 +3553,13 @@ $gro->timecreated = backup_todb($info['GROUPING']['#']['TIMECREATED']['0']['#']); //Now search if that group exists (by name and description field) in - if ($gro_db = get_record('groupings', 'courseid', $restore->course_id, 'name', $gro->name, 'description', $gro->description)) { + // MOD -- MSSQL doesn't like using text or ntext columns in WHERE clauses, so we need to cast it as a varchar + $gro_db = get_record_sql('SELECT * FROM '. $CFG->prefix . "groupings WHERE + courseid = '{$restore->course_id}' AND name='{$gro->name}' + AND " . sql_compare_text('description') . " = '{$gro->description}'"); + if($gro_db) { + //if ($gro_db = get_record('groupings', 'courseid', $restore->course_id, 'name', $gro->name, 'description', $gro->description)) { + // End MOD //get current group id $newid = $gro_db->id;