General help

Error on deleting users

 
Picture of koen roggemans
Error on deleting users
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

I have a weird error when deleting users:

Notice: Trying to get property of non-object in /var/www/elo/moodle/lib/grade/grade_grade.php on line 1080

Notice: Trying to get property of non-object in /var/www/elo/moodle/lib/classes/event/grade_deleted.php on line 70

Can not find data record in database table course.

Moodle version is Moodle 3.3.3 (Build: 20171113)


This doesn't happen with all users when clicking the cross in "Browse list of users", but it happens always if I use "Bulk user actions" or "Upload users" with CSV using username and delete fields.

Some users I can't delete at all. So I have the impression there is some data for some users that breaks the delete script. I couldn't find any bugs that look similar. I tried to bulk delete the two users on the demo site and that worked smile

Has anyone an idea where to start my investigation?


 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: Error on deleting users
Core developersParticularly helpful MoodlersPlugin developers

Hi Koen,
from https://github.com/moodle/moodle/blob/MOODLE_33_STABLE/lib/grade/grade_grade.php#L1080 and https://github.com/moodle/moodle/blob/MOODLE_33_STABLE/lib/classes/event/grade_deleted.php#L70, it looks like grade_item is not an object, null or probably false (DB table, grade_grades).

The code should check for something like empty() and skip those items.

HTH,
Matteo

 
Average of ratings: -
Picture of koen roggemans
Re: Error on deleting users
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

Thank you for your response Matteo.

It seems like I'm not the only one. In the mean time I found

https://tracker.moodle.org/browse/MDL-51694

https://moodle.org/mod/forum/discuss.php?d=335075

I used 

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

from the tracker issue and found 2084 records on a total of 707849.


I deleted them with

DELETE from mdl_grade_grades where itemid not in (select id from mdl_grade_items)
which was mentioned in the bug.

After running the delete query all was working fine again and I managed to delete the 400 users.

I think your suggested code change would have worked too, but I preferred in this case to clean up the database - it might prevent future problems.


 
Average of ratings: Useful (1)