Error when Deleting Users

Error when Deleting Users

by Kevin Ratcliffe -
Number of replies: 4
Hi All

I hope someone can help me with this issue. When I try to delete certain users, I get the following message.
Can not 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 1455 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
    line 1431 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
    line 6884 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 1036 of /lib/grade/grade_grade.php: call to core\event\grade_deleted::create_from_grade()
    line 1335 of /lib/gradelib.php: call to grade_grade->delete()
    line 3946 of /lib/moodlelib.php: call to grade_user_delete()
    line 90 of /admin/user.php: call to delete_user()
This doesn't happen to all users that I try to remove. But this is a problem when bulk deleting users.

I'm using Moodle 2.9

Thanks for any pointers or suggestions.

Kev
Average of ratings: -
In reply to Kevin Ratcliffe

Re: Error when Deleting Users

by Paul Nijbakker -
Hi Kev, We are using Moodle 3.1.7 and are having exactly the same problem. We have a somewhat big site and removing, say, 4000 users becomes quite a chore when one has to do it one by one. Did you find any solution to this issue? Rgrds, Paul.
In reply to Paul Nijbakker

Re: Error when Deleting Users

by Miriam Bérubé -
I have recently started having the same issue. I have Moodle 3.1 on my site.  I cannot always delete users and the site shows the same error:


But after a few tries, I am able to delete the user.  It's very frustrating, especially when trying to delete using bulk user actions. I have to try to delete individually and keep trying until succesful.


Any help would be appreciated!

In reply to Miriam Bérubé

Re: Error when Deleting Users

by Kamille Guevarra -

Hi Guys! 

We are also experiencing error when deleting users, around 800 users. We've tried downloading csv file then uploading it for deletion and always ends with an error. Then we've tried creating a cohort, then use bulk user action, still, same error. 

Do you guys know any workaround? 

Appreciate the help!

In reply to Kamille Guevarra

Re: Error when Deleting Users

by C Behan -

I experienced something similar before.  It was a result of previously restoring courses with users from another old Moodle site in to our main Moodle site. 

Our vendor found out the issue was caused by some legacy grade data not being properly cleaned up from the database. Some of these grade data belonged to the users to be deleted, and error occurred when trying to get details of these grade data. Our vendor cleaned up the grade data in the database which resolved the issue.