Affects Version/s: 2.8.6
Fix Version/s: None
We noticed that some aspects of our cron tasks were not running. Looking through the cron log we saw that when the lagacy cron runner ran it was failing with an "Invalid course module ID" error. After doing some tracing I narrowed the error down to happening at the update_calendar line in the block below:
Line 1863 mod/assign/locallib.php
Inside that update_calendar method Moodle is trying to fetch a course_module record for the passed in course module ID. Despite having a record in the DB for some reason the code was claiming that the course module was invalid. Looking at the record I noticed that the associated name for the course module was "0"(zero).
It looks like the course_modinfo constructor ignores modules if their name fails the PHP empty test:
course_modinfo constructor around line 492
When we changed the name of the module to something else the problem went away. Unfortunately this more or less kills some aspects of our site since once that cron task fails none of the rest of that cron task runs. We can try to advise our users to not name stuff "0" but that is not a silver bullet.
I think Moodle should really be a tad more robust in this specific instance so that cron tasks for the whole site are not brought to a halt due to an unfortunate naming scheme.
There are probably a wide array of approaches for addressing this, but I think that maybe the course_modinfo constructor should maybe be checking for empty strings (or even false) instead of using the PHP empty check.