[3.9.1] Can't find data record in database table course.

[3.9.1] Can't find data record in database table course.

per Richard van Iwaarden,
Number of replies: 1
Avatar Particularly helpful Moodlers

When trying to delete a specific user, I get this error:

Can't find data record in database table course.

More information about this error

×Debug info: SELECT id,category FROM {course} WHERE id IS NULL
[array (
)]
Error code: invalidrecord
×Stack trace:
  • line 1599 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 1575 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
  • line 6928 of /lib/accesslib.php: call to moodle_database->get_record()
  • line 70 of /lib/classes/event/grade_deleted.php: call to context_course::instance()
  • line 1122 of /lib/grade/grade_grade.php: call to core\event\grade_deleted::create_from_grade()
  • line 1536 of /lib/gradelib.php: call to grade_grade->delete()
  • line 4242 of /lib/moodlelib.php: call to grade_user_delete()
  • line 107 of /admin/user.php: call to delete_user()
It seems to me there's a reference somewhere in the grades table that's not OK.

But how to find it? The above was the max info I could get (debug logging on)
Average of ratings  -
In reply to Richard van Iwaarden

Re: [3.9.1] Can't find data record in database table course.

per Richard van Iwaarden,
Avatar Particularly helpful Moodlers
Just tried to delete another user, that works fine. So it has to do with this specific user.