-
Bug
-
Resolution: Not a bug
-
Minor
-
None
-
4.5, 5.0
-
MOODLE_405_STABLE, MOODLE_500_STABLE
-
-
In certain situations, the get_completion_data method of the completion_info class can return data which can not be inserted into the completion data table.
Specifically, if a record exists in the course_modules_viewed table but not in the course_modules_completion table then the get_completion_data method will return an array where completionstate and timemodified are both null. The course_modules_completion table definition does not allow either of those columns to be null.
The functional impact is that because the database table definition doesn't allow either those values to be null, any code that naively updates the value returned by the get_completion_data method (or the get_data method because it calls get_completion_data and also returns that value) and then tries to save the updated value will trigger a fatal database error.
In practice, this problem can occur with the Moodle Workplace course_reset_api where the reset_module_viewed method updates the viewed status of the returned data and attempts to save the result without confirming that the completionstate and timemodified columns have valid data.
Note: The bug outlined in MDL-83946 is one way for viewed records to exist without matching completion records.
- has been marked as being related by
-
MDL-83946 Function delete_all_state doesn't delete all state.
-
- Closed
-