-
Bug
-
Resolution: Fixed
-
Minor
-
2.6
-
MOODLE_26_STABLE
-
MOODLE_25_STABLE, MOODLE_26_STABLE
-
MDL-44065-master -
When creating a module, the following sequence of events happens in the database:
(...)
1. mdl_course_modules row created with instance = 0
2. (module table row created via module_add_instance)
3. mdl_course_modules instance value set
(...)
If an exception is thrown during the module_add_instance function, this can result in the situation where a mdl_course_modules row with instance = 0 exists. Generally this row is ignored but it can cause problems with custom modules - for example, the module_get_coursemodule_info function will be called when rebuilding course cache, and if that function fails to handle the case where instance is 0, then the course page cannot be viewed.
While this inconsistent data does not cause obvious problems for core Moodle (as noted, we saw this issue with a custom module that was not tolerant of the situation - probably core modules are designed to allow it), I suggest that to support those Moodle users who care about database consistency and reduce the likelihood of this problem occurring for custom plugin developers, we should fix this problem.
Note: In OU installation of Moodle, we have evidence for this problem occurring in 9 modules of which 2 are core (resource, url) and one is non-OU third party; the others are all our modules. However I suspect the core ones may have been introduced by events in our custom code, or by custom repository code, etc. and are not actually possible in core Moodle.
- has a non-specific relationship to
-
MDL-38228 Major Performance Problem with "Moving Modules" upgrade step
-
- Closed
-