$restore->backup_version = $info->backup_backup_version;
makes the backup version number from the backup file available to the restore code. That is coming from the <INFO>/<BACKUP_VERSION> tag in the backup XML file.
My question is: has that tag always been there? I am getting error reports from people trying to restore 1.4 backups incuding quiz questions. The problem is quiz question types used to be integers, and now they are strings, so they need to be converted. However the codeif ($restore->backup_version < 2006032200) { // The qtype was an integer that now needs to be converted to the name $qtypenames = array(1=>'shortanswer',2=>'truefalse',3=>'multichoice',4=>'random',5=>'match', 6=>'randomsamatch',7=>'description',8=>'numerical',9=>'multianswer',10=>'calculated', 11=>'rqp',12=>'essay'); $question->qtype = $qtypenames[$question->qtype]; }
is already there. It is just not having any effect with old backup files. I am wondering whether $restore->backup_version may be undefined when restoring really old backup files, and therefore we need to apply the following patch? (I don't know the backup/restore code well enough to be sure.)
Index: backup/restore_execute.html =================================================================== RCS file: /cvsroot/moodle/moodle/backup/restore_execute.html,v retrieving revision 1.57 diff -u -r1.57 restore_execute.html --- backup/restore_execute.html 3 Jun 2006 20:18:02 -0000 1.57 +++ backup/restore_execute.html 8 Aug 2006 16:57:10 -0000 @@ -15,7 +15,11 @@ $restore->original_wwwroot = $info->original_wwwroot; //Add info->backup_version to $restore to be able to detect versions in the restore process //(to decide when to convert wiki texts to markdown...) - $restore->backup_version = $info->backup_backup_version; + if (!empty($info->backup_backup_version)) { + $restore->backup_version = $info->backup_backup_version; + } else { + $restore->backup_version = 0; + } //Check login require_login();