-
Bug
-
Resolution: Fixed
-
Major
-
3.5.12, 3.8.3, 3.10, 3.11.6, 3.11.8, 4.0, 4.0.1, 4.0.2
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_35_STABLE, MOODLE_38_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MDL-68843-master -
When a tool is published within a course, if the associated tool is removed from the course, the "Published as LTI Tools" menu will end up inaccessible due to an "Can't find data record in database table context." exception.
It seems like the adhoc task that deletes the course modules leaves an inconsistency in the database. In the "enrol_lti_tools" table it remains the row pointing to a context that no longer exists. This can be detected with a simple query:
Steps to replicate:
- Enable LTI authentication and LTI enrol method in your site.
- Create a quiz activity module in a course.
- Go in this same course to the "Published as LTI Tools" menu and add this quiz as a published tool.
- Go back to the course and delete the quiz.
- Wait until the adhoc task "course_delete_modules" runs and completely removes the activity module.
- Check the "Published as LTI Tools" menu, you should see a "Can't find data record in database table context." exception.
SELECT elt.* |
FROM mdl_enrol_lti_tools elt |
WHERE elt.contextid NOT IN (SELECT ctx.id FROM mdl_context ctx) |
There should be a handler observing the \core\event\course_module_deleted event in order to delete the shared tool as soon as a tool is removed within the course.
It could be handled directly in the course_delete_module function in /course/lib.php as well.
For posterity, the original branch which was attached here is below:
Repo: https://github.com/Royerino/moodle
Branch: MDL-68843-master
Diff: https://github.com/moodle/moodle/compare/master...Royerino:MDL-68843-master