As I was unable to reopen the ticket #
MDL-67706, and I still believe there is an underlying issue.
Here is some complement of information that I am hoping will help to keep this ticket open this way around. I can totally understand that this cannot be reproduced on the demo site on your side, but if the only criteria for fixing an issue ( which is, in our case visible in the code) is to be able to reproduce it on the demo site, I am suddenly being worried about the way we, as a community, can help to improve moodle. Our site is maybe a special case but I really doubt it.
To be constructive, what I can offer here is a fix and unit tests to prove that the issue is fixed.
I think there are strong argument to fix the issue for good.
- I still believe that the deletion operation should either be more explicit in explaining the exact underlying issue to the user or having a way to go through grade deletion without raising an exception, so it is not just a cryptic message.
- It puts the moodle administration between a rock and a hard place: the given users cannot be deleted whatever we try.
- I have found multiple mentions of missing id /foreign key issues regarding gradebook, although it seem to affect only some older installations.
On the bright side, it seems that someone already offered a solution for the exact same problem https://tracker.moodle.org/browse/MDL-51694?focusedCommentId=477650&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-477650
I suppose that the patch proposed there would work and that it should be integrated in the main 35/36 line (the patch was for 3.1 I think).
I can develop and test the same patch if needed + add one or two unit tests on a 3.5+ (LTS) branch. We would also need to link this ticket to #