Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-24189 data module restore - Fix 1.x comments and ratings restore.…

… Were missing user remappings. Backported from 19_STABLE
  • Loading branch information...
commit 77a6439afa4c30f553d9d636cb625c70052d8669 1 parent 05dd6e5
@stronk7 stronk7 authored
Showing with 23 additions and 8 deletions.
  1. +1 −0  mod/data/backuplib.php
  2. +22 −8 mod/data/restorelib.php
View
1  mod/data/backuplib.php
@@ -238,6 +238,7 @@ function backup_data_comments($bf,$preferences,$recordid){
fwrite ($bf,full_tag("RECORDID",8,false,$com_sub->recordid));
fwrite ($bf,full_tag("USERID",8,false,$com_sub->userid));
fwrite ($bf,full_tag("CONTENT",8,false,$com_sub->content));
+ fwrite ($bf,full_tag("FORMAT",8,false,$com_sub->format));
fwrite ($bf,full_tag("CREATED",8,false,$com_sub->created));
fwrite ($bf,full_tag("MODIFIED",8,false,$com_sub->modified));
//End submission
View
30 mod/data/restorelib.php
@@ -394,9 +394,15 @@ function data_ratings_restore_mods ($oldid, $newid, $info, $rec_info) {
$rat_info = $ratings[$i];
- $rating -> recordid = $newid;
- $rating -> userid = backup_todb($rat_info['#']['USERID']['0']['#']);
- $rating -> rating = backup_todb($rat_info['#']['RATING']['0']['#']);
+ $rating->recordid = $newid;
+ $rating->userid = backup_todb($rat_info['#']['USERID']['0']['#']);
+ $rating->rating = backup_todb($rat_info['#']['RATING']['0']['#']);
+
+ // Need to remap the user
+ $user = backup_getid($restore->backup_unique_code,"user",$rating->userid);
+ if ($user) {
+ $rating->userid = $user->new_id;
+ }
if (! insert_record ("data_ratings",$rating)) {
$status = false;
@@ -421,11 +427,19 @@ function data_comments_restore_mods ($oldid, $newid, $info, $rec_info) {
$com_info = $comments[$i];
- $comment -> recordid = $newid;
- $comment -> userid = backup_todb($com_info['#']['USERID']['0']['#']);
- $comment -> content = backup_todb($com_info['#']['CONTENT']['0']['#']);
- $comment -> created = backup_todb($com_info['#']['CREATED']['0']['#']);
- $comment -> modified = backup_todb($com_info['#']['MODIFIED']['0']['#']);
+ $comment->recordid = $newid;
+ $comment->userid = backup_todb($com_info['#']['USERID']['0']['#']);
+ $comment->content = backup_todb($com_info['#']['CONTENT']['0']['#']);
+ $comment->format = backup_todb($com_info['#']['FORMAT']['0']['#']);
+ $comment->created = backup_todb($com_info['#']['CREATED']['0']['#']);
+ $comment->modified = backup_todb($com_info['#']['MODIFIED']['0']['#']);
+
+ // Need to remap the user
+ $user = backup_getid($restore->backup_unique_code,"user",$comment->userid);
+ if ($user) {
+ $comment->userid = $user->new_id;
+ }
+
if (! insert_record ("data_comments",$comment)) {
$status = false;
}
Please sign in to comment.
Something went wrong with that request. Please try again.