Bug #6099 - Restore alternatively failing on data module - fixed status codes of module restore process
This commit is contained in:
+4
-2
@@ -411,8 +411,10 @@
|
||||
$rec->old_id = $old_id;
|
||||
$rec->new_id = ($new_id === null? 0 : $new_id);
|
||||
$rec->info = $info_to_save;
|
||||
|
||||
$status = insert_record('backup_ids', $rec, false);
|
||||
|
||||
if (!insert_record('backup_ids', $rec, false)) {
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
@@ -2489,7 +2489,7 @@
|
||||
$modrestore = $mod->modtype."_restore_mods";
|
||||
if (function_exists($modrestore)) {
|
||||
//print_object ($mod); //Debug
|
||||
$status &= $modrestore($mod,$restore);
|
||||
$status = $status and $modrestore($mod,$restore); //bit operator & not reliable here!
|
||||
} else {
|
||||
//Something was wrong. Function should exist.
|
||||
$status = false;
|
||||
|
||||
+24
-13
@@ -100,9 +100,9 @@ function data_restore_mods($mod,$restore) {
|
||||
}
|
||||
if ($restore_userdata_selected) {
|
||||
//Restore data_fields first!!! need to hold an array of [oldid]=>newid due to double dependencies
|
||||
$status = data_fields_restore_mods ($mod->id, $newid, $info, $restore);
|
||||
$status = data_records_restore_mods ($mod->id, $newid, $info, $restore);
|
||||
|
||||
$status = $status and data_fields_restore_mods ($mod->id, $newid, $info, $restore);
|
||||
$status = $status and data_records_restore_mods ($mod->id, $newid, $info, $restore);
|
||||
|
||||
}
|
||||
} else {
|
||||
$status = false;
|
||||
@@ -172,6 +172,8 @@ function data_records_restore_mods ($old_data_id, $new_data_id, $info, $restore)
|
||||
|
||||
global $CFG, $fieldids;
|
||||
|
||||
$status = true;
|
||||
|
||||
$records = $info['MOD']['#']['RECORDS']['0']['#']['RECORD'];
|
||||
|
||||
for ($i = 0; $i < sizeof($records); $i++) {
|
||||
@@ -206,12 +208,12 @@ function data_records_restore_mods ($old_data_id, $new_data_id, $info, $restore)
|
||||
|
||||
if ($newid) {
|
||||
//We have the newid, update backup_ids
|
||||
$status = backup_putid($restore->backup_unique_code,"data_records",$oldid, $newid);
|
||||
$status = $status and backup_putid($restore->backup_unique_code,"data_records",$oldid, $newid);
|
||||
|
||||
$status = $status and data_content_restore_mods ($oldid, $newid, $old_data_id, $new_data_id, $rec_info, $restore);
|
||||
$status = $status and data_ratings_restore_mods ($oldid, $newid, $info, $rec_info);
|
||||
$status = $status and data_comments_restore_mods ($oldid, $newid, $info, $rec_info);
|
||||
|
||||
$status = data_content_restore_mods ($oldid, $newid, $old_data_id, $new_data_id, $rec_info, $restore);
|
||||
$status = data_ratings_restore_mods ($oldid, $newid, $info, $rec_info);
|
||||
$status = data_comments_restore_mods ($oldid, $newid, $info, $rec_info);
|
||||
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
@@ -223,6 +225,8 @@ function data_content_restore_mods ($old_record_id, $new_record_id, $old_data_id
|
||||
|
||||
global $CFG, $fieldids;
|
||||
|
||||
$status = true;
|
||||
|
||||
$contents = $recinfo['#']['CONTENTS']['0']['#']['CONTENT'];
|
||||
|
||||
for ($i = 0; $i < sizeof($contents); $i++) {
|
||||
@@ -254,10 +258,9 @@ function data_content_restore_mods ($old_record_id, $new_record_id, $old_data_id
|
||||
|
||||
if ($newid) {
|
||||
//We have the newid, update backup_ids
|
||||
|
||||
|
||||
$status = data_restore_files ($old_data_id, $new_data_id, $oldfieldid, $content->fieldid, $oldrecordid, $content->recordid, $recinfo, $restore);
|
||||
$status = backup_putid($restore->backup_unique_code,"data_content",$oldid, $newid);
|
||||
$status = $status and data_restore_files ($old_data_id, $new_data_id, $oldfieldid, $content->fieldid, $oldrecordid, $content->recordid, $recinfo, $restore);
|
||||
$status = $status and backup_putid($restore->backup_unique_code,"data_content",$oldid, $newid);
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
@@ -324,6 +327,8 @@ function data_ratings_restore_mods ($oldid, $newid, $info, $rec_info) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$ratings= $rec_info['#']['RATINGS']['0']['#']['RATING'];
|
||||
|
||||
if (empty($ratings)) { // no ratings to restore
|
||||
@@ -337,7 +342,9 @@ function data_ratings_restore_mods ($oldid, $newid, $info, $rec_info) {
|
||||
$rating -> userid = backup_todb($rat_info['#']['USERID']['0']['#']);
|
||||
$rating -> rating = backup_todb($rat_info['#']['RATING']['0']['#']);
|
||||
|
||||
$status = insert_record ("data_ratings",$rating);
|
||||
if (! insert_record ("data_ratings",$rating)) {
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
@@ -346,6 +353,8 @@ function data_comments_restore_mods ($oldid, $newid, $info, $rec_info) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$comments= $rec_info['#']['COMMENTS']['0']['#']['COMMENT'];
|
||||
|
||||
if (empty($comments)) { // no comments to restore
|
||||
@@ -361,7 +370,9 @@ function data_comments_restore_mods ($oldid, $newid, $info, $rec_info) {
|
||||
$comment -> content = backup_todb($com_info['#']['CONTENT']['0']['#']);
|
||||
$comment -> created = backup_todb($com_info['#']['CREATED']['0']['#']);
|
||||
$comment -> modified = backup_todb($com_info['#']['MODIFIED']['0']['#']);
|
||||
$status = insert_record ("data_comments",$comment);
|
||||
if (! insert_record ("data_comments",$comment)) {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
}
|
||||
return $status;
|
||||
|
||||
Reference in New Issue
Block a user