-
Bug
-
Resolution: Fixed
-
Major
-
2.0.8, 2.1, 2.2
-
MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
-
MOODLE_21_STABLE, MOODLE_22_STABLE
-
The class data_object is the base of all completion classes. It was originally subclasses from grade_object as it was assumed this was a good piece of code to base a similar solution on ( how wrong we were! ).
It has be come apparent that the constructor is a bit too specific with it's where clauses, and if it is used to fetch a record it will include all data passed to it in the where clause. This causes issues as sometimes it will fail to locate a record in the database, and instead of updating will insert a duplicate record causing issues later on. This seems to occur frequently due to issues with concurrency, especially since a lot of work is passed off to the cron and a lot of calls to the constructor include unneccessary data like timemodified.
Attached is the code to fix this issue, which is the cause of a majority of the duplicate record issues in course completion. It has been tried and tested in it's 1.9 form in Totara for many months now.
The next step is to add unique indexes to relevant tables, but I understand that has to happen in master as is a database change while I am hoping this commit can make it's way into earlier versions.
- blocks
-
MDL-28949 Duplicated course completion entries in database not handled correctly
- Closed
-
MDL-31441 Course completion/"Found more than one record in fetch() bug not fixed yet
- Closed
-
MDL-32103 Make course completion instant for activity based completion criteria (single user completions only)
- Closed