moodleou / moodle-mod_subpage

Subpage module allows you to add Moodle activities onto inner page within course
21 stars 15 forks source link

Duplicating/Importing/Restoring errors with mdl_subpsect_sec_uix violation on 2nd run #13

Closed supton-overtsoftware closed 8 years ago

supton-overtsoftware commented 9 years ago

When importing a subpage more than once it returns an error (at the bottom) and it's exhibited it on 2014092900. When debugging the following line in 'restore_subpage_activity_task_class.php' (line 128) doesn't return a value and never replaces the temp IDs.

$mappingrecord = restore_dbops::get_backup_ids_record(
        $restoreid, 'course_section', $oldsectionid);
Debug info: Duplicate entry '10012319' for key 'mdl_subpsect_sec_uix'
INSERT INTO mdl_subpage_sections (sectionid,pageorder,stealth,subpageid) VALUES(?,?,?,?)
[array (
0 => 10012319,
1 => '1',
2 => '0',
3 => 1504,
)]
Error code: dmlwriteexception
Stack trace:
line 446 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 1164 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1210 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
line 72 of /mod/subpage/backup/moodle2/restore_subpage_stepslib.php: call to mysqli_native_moodle_database->insert_record()
line 137 of /backup/util/plan/restore_structure_step.class.php: call to restore_subpage_activity_structure_step->process_subpage_sections()
line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
line 178 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
line 190 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
line 278 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
line ? of unknownfile: call to progressive_parser->end_tag()
line 179 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
line 110 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
line 195 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
line 177 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
line 167 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
line 333 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
line 163 of /backup/import.php: call to restore_controller->execute_plan()
sammarshallou commented 9 years ago

We don't support backup/restore of subpage individually (i.e. in any way other than restoring the whole course), except for using the new 'copy subpage to another website' button that was added recently. Probably best to use that feature if possible...

(For info: when doing a full course restore the temp IDs are put back, i.e. it subtracts 10 million again, in the after_restore function in restore_subpage_activity_task.php.)

When you get the temp IDs stuck in the database you can clear them by visiting mod/subpage/deletebaddata.php (see code comments for usage information).

Hope this helps? I don't think it's possible to make the individual backup/restore work properly because of the way it depends on other sections etc.

supton-overtsoftware commented 8 years ago

Thanks for the speedy response and apologies for the delay. It looks like it was a symptom from a previous partial restore.