Details
Description
We were trying to run the script admin/cli/fix_orphaned_question_categories.php because we seem to have 10k> orphaned categories on our system.
When run with --fix, it eventually stops on a category giving an error like this:
Found orphaned category: Default for Q4 R&J A3
|
Cleaning...!!! Can't find data record in database table context. !!!
|
!! SELECT * FROM {context} WHERE id = ?
|
[array (
|
0 => '284088',
|
)]
|
Error code: invalidrecord !!
|
!! Stack trace: * line 1562 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
|
* line 1538 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
|
* line 5213 of /lib/accesslib.php: call to moodle_database->get_record()
|
* line 221 of /lib/classes/event/base.php: call to context::instance_by_id()
|
* line 125 of /lib/classes/event/question_base.php: call to core\event\base::create()
|
* line 383 of /lib/questionlib.php: call to core\event\question_base::create_from_question_instance()
|
* line 271 of /lib/questionlib.php: call to question_delete_question()
|
* line 87 of /admin/cli/fix_orphaned_question_categories.php: call to question_category_delete_safe()
|
!!
|
Pretty sure this is when it gets to the first category that has questions in it it needs to deal with. I haven't looked deep into it yet, but from the trace it seems pretty clear that it is attempting to fire an event for deleting a question, but the context doesn't exist (since this tool is exactly looking for categories in non-existent contexts...)
Attachments
Issue Links
- has a non-specific relationship to
-
MDL-47787 After deleting a quiz, its question categories and questions remain in database
-
- Closed
-