moodleou / moodle-report_embedquestion

Work in progress. Do not use yet.
1 stars 4 forks source link

EmbedQuestion Breaks Recycle Bin #6

Closed aspark21 closed 3 years ago

aspark21 commented 4 years ago

Moodle: 3.9.2 EmbedQuestion: master Behat scenario: Delete and restore a quiz with user data # /var/www/html/admin/tool/recyclebin/tests/behat/backup_user_data.feature:24

Manual testing of this, encounters the following:

Debug info: Error code: generalexceptionmessage Stack trace: line 33 of /backup/moodle2/backup_stepslib.php: Error thrown line 26 of /report/embedquestion/backup/moodle2/backup_report_embedquestion_plugin.class.php: call to require_once() line 283 of /backup/util/plan/restore_structure_step.class.php: call to require_once() line 4237 of /backup/moodle2/restore_stepslib.php: call to restore_structure_step->add_plugin_structure() line 84 of /backup/util/plan/restore_structure_step.class.php: call to restore_module_structure_step->define_structure() line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute() line 210 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute() line 178 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute() line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute() line 384 of /backup/controller/restore_controller.class.php: call to restore_plan->execute() line 265 of /admin/tool/recyclebin/classes/course_bin.php: call to restore_controller->execute_plan() line 101 of /admin/tool/recyclebin/index.php: call to tool_recyclebin\course_bin->restore_item() Output buffer:

Did you remember to make the first column something unique in your call to get_records? Duplicate value 'value-removed-for-github' found in column 'concat(stamp, ' ', version)'. line 1282 of /lib/dml/mysqli_native_moodle_database.php: call to debugging() line 1548 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql() line 680 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_records_sql_menu() line 518 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::prechek_precheck_qbanks_by_level() line 178 of /backup/util/helper/restore_prechecks_helper.class.php: call to restore_dbops::precheck_categories_and_questions() line 427 of /backup/controller/restore_controller.class.php: call to restore_prechecks_helper::execute_prechecks() line 248 of /admin/tool/recyclebin/classes/course_bin.php: call to restore_controller->execute_precheck() line 101 of /admin/tool/recyclebin/index.php: call to tool_recyclebin\course_bin->restore_item()

aspark21 commented 4 years ago

Assuming workaround is similar than for #2 , any likelihood of this being fixable? (Have dev time available on our end this week in the run up to our upgrade to 3.9)

aspark21 commented 4 years ago

Can see both MDLs have been integrated so code should be working in 3.9 - https://github.com/moodleou/moodle-report_embedquestion/commit/76b8d66eae927b888bb989adf36d7933da142453

Workaround applied for now.

timhunt commented 4 years ago

The error you report is nothign to do with #2. No idea why that is happening, but we don't see it here.

timhunt commented 3 years ago

So, the issue is a unqiue key violation, but I can't see why that would be happening. Also, the error is happening in the questoin bank backup/restore code.

What is the evidence that this plugin is involved in the bug? One mention in a stack trace. But, only the point where one of our files does a require_once - and you cut off the acutal error message related to that, and only gave the debug info.

I don't really see what I can do about this.

nadavkav commented 3 years ago

I am also experiencing the same issue, but only on some courses in our system. weird. Some deleted recyclebin restore links work, and some don't. Debugging...

kirildevlion commented 3 years ago

You can add require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); before: require_once($CFG->dirroot . '/backup/moodle2/backup_stepslib.php'); in file: report/embedquestion/backup/moodle2/backup_report_embedquestion_plugin.class.php and it solved the problem (Moodle 3.9).

nadavkav commented 3 years ago

@kirildevlion patch fixed this issue for me

timhunt commented 3 years ago

Thanks for the info. I don't understand why it is only breaking on some courses, not others, but the suggested fix is clearly safe, so I will implement it.

timhunt commented 3 years ago

OK, new version pushed (here and plugins DB) which adds the extra require_once.