Error trying to delete a user

Error trying to delete a user

by Juan Manuel Zolezzi Volpi -
Number of replies: 1
We are running an updated Moodle installation with 3.8.3, but it's reporting an error trying to delete a user:

No se puede encontrar registro de datos en la tabla course de la base de datos.

Información de depuración: SELECT id,category FROM {course} WHERE id IS NULL
[array (
)]
Error code: invalidrecord
Trazado de la pila (stack):
  • 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 6894 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 1534 of /lib/gradelib.php: call to grade_grade->delete()
  • line 4238 of /lib/moodlelib.php: call to grade_user_delete()
  • line 107 of /admin/user.php: call to delete_user()

Any idea on what could be causing this, or how to debug it?
Average of ratings: -
In reply to Juan Manuel Zolezzi Volpi

Re: Error trying to delete a user

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

This looks like MDL-51694. As far as I can tell the problem that leads to this error has been fixed but for sites that already have this problem there's currently no fix.

I've added a comment to the Tracker issue asking for more information. You can run the SELECT statement to see if there any rows are returned:

select * from mdl_grade_grades where itemid not in (select id from mdl_grade_items)

If rows are returned – if there was no problem then there shouldn't be – there's a suggested DELETE statement to tidy those up, ensure you have a database backup before making any changes to the database:

DELETE from mdl_grade_grades where itemid not in (select id from mdl_grade_items)

Average of ratings: Useful (1)