David Mudrák
added a comment - 12/Apr/08 2:02 PM Please, forget the last sentence of the Description. The module has to be deleted manually. This is the reply:
The required instance of this module didn't exist. Module deleted.

Petr Skoda
added a comment - 13/May/08 4:02 AM I heard some ppl are having activities without entries in course_module table (ask sam from OU if needed
but the opposite should never happen
+1 for 1.8 and 1.9 branches

Jeffrey Silverman
added a comment - 11/Jun/08 7:27 PM Never mind, figured it out. I'll answer here anyway for the legions of interested people flocking to this page.
The "instance" column is the id of the module, pointing to the modulename table. So, for example, a "label":
mdl_course_module.instance joins to mdl_label.id

Yes Jeffrey, you are right. The "instance" is the ID of the module record in its own table. In "mdl_course_modules" we define just "slots" where module instances can be put into.

Ad this issue: I have not committed yet, because I want to check yet another approach: the restorelib should remember which slots (i.e. course_modules) were created during the restore process. At the end of the restore, only empty slots created in this restore process are deleted. This should prevent potential problems with concurrent (parallel) restore processes. In the current proposal, one running restore process could remove empty course_modules slots created by another (and still running!) restore process.

David Mudrák
added a comment - 11/Jun/08 7:59 PM Yes Jeffrey, you are right. The "instance" is the ID of the module record in its own table. In "mdl_course_modules" we define just "slots" where module instances can be put into.
Ad this issue: I have not committed yet, because I want to check yet another approach: the restorelib should remember which slots (i.e. course_modules) were created during the restore process. At the end of the restore, only empty slots created in this restore process are deleted. This should prevent potential problems with concurrent (parallel) restore processes. In the current proposal, one running restore process could remove empty course_modules slots created by another (and still running!) restore process.

I'm experiencing this problem in Moodle 1.9.2 (Build: 20080711). Is there a patch available for this yet? Faculty are starting to hit Moodle as they ramp up for the fall semester and are encountering this problem in droves. If it helps, I can confirm that "DELETE FROM course_modules where instance=0" gets ride of the ghost activities.

Kenneth Newquist
added a comment - 13/Aug/08 11:03 PM I'm experiencing this problem in Moodle 1.9.2 (Build: 20080711). Is there a patch available for this yet? Faculty are starting to hit Moodle as they ramp up for the fall semester and are encountering this problem in droves. If it helps, I can confirm that "DELETE FROM course_modules where instance=0" gets ride of the ghost activities.

To clarify, what I'm seeing is the behavior reported in <a href="http://tracker.moodle.org/browse/MDL-10993"> MDL-10993: Restore creates duplicate activity/resource icons with no text</a>. We get these duplicates when importing a course into a new blank course (rather than restoring from a backup). It appears to be intermittent; I can reproduce it on my development system but not my production one, yet I have reports of this happening in production as well.

The "DELETE FROM" line removed the duplicates however, as the tracker notes, fixing this will likely help with my problem as well.

Kenneth Newquist
added a comment - 13/Aug/08 11:34 PM To clarify, what I'm seeing is the behavior reported in <a href="http://tracker.moodle.org/browse/MDL-10993"> MDL-10993 : Restore creates duplicate activity/resource icons with no text</a>. We get these duplicates when importing a course into a new blank course (rather than restoring from a backup). It appears to be intermittent; I can reproduce it on my development system but not my production one, yet I have reports of this happening in production as well.
The "DELETE FROM" line removed the duplicates however, as the tracker notes, fixing this will likely help with my problem as well.

I have had the same issues on multiple sites and this patch should resolve the issue with duplicate icons being created during Backup/Restore or import to new or existing course. moodle/backup/restorelib.php patch...

John T. Macklin
added a comment - 19/Aug/08 8:24 AM I have had the same issues on multiple sites and this patch should resolve the issue with duplicate icons being created during Backup/Restore or import to new or existing course. moodle/backup/restorelib.php patch...

MDL-14326-commited.patch - modified John's patch. It removes all course_modules that remained empty (i.e. with instance==0) after the particular restore process. The patch does not contain other Remote Learner modifications from the John's patch (i.e. ini_setting max executable time and ignoring mod/resource restore failures). Track these modification in a separate issue if needed.

David Mudrák
added a comment - 21/Aug/08 7:24 PM MDL-14326 -commited.patch - modified John's patch. It removes all course_modules that remained empty (i.e. with instance==0) after the particular restore process. The patch does not contain other Remote Learner modifications from the John's patch (i.e. ini_setting max executable time and ignoring mod/resource restore failures). Track these modification in a separate issue if needed.

Tim Hunt
added a comment - 22/Dec/08 1:29 PM Hmm. does this leave orphan contexts floating around? That is, should be be calling delete_course_module from course/lib.php rather than calling delete records?

The issue here was additional modules instances if you check grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$modulename,
'iteminstance'=>$cm->instance, 'courseid'=>$cm->course))) against one of these additional instances you will not find any grade_items or
events since the $cm->instance is invalid. Hence why I did not use delete_course_module from course/lib.php .

John T. Macklin
added a comment - 23/Dec/08 12:44 AM Tim,
The issue here was additional modules instances if you check grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$modulename,
'iteminstance'=>$cm->instance, 'courseid'=>$cm->course))) against one of these additional instances you will not find any grade_items or
events since the $cm->instance is invalid. Hence why I did not use delete_course_module from course/lib.php .

We are running version 1.8.8 and this problem still exists. Not sure about during restore but it occurred during import. After importing contents, empty resources appeared in various weeks and when clicking them the following error occurs:The required instance of this module didn't exist. Module deleted. But it doesn't actually delete. I could go back in and manually delete the empty modules, but why does this still occur? Same bug or different one?

Susan Mangan
added a comment - 15/May/09 6:57 AM We are running version 1.8.8 and this problem still exists. Not sure about during restore but it occurred during import. After importing contents, empty resources appeared in various weeks and when clicking them the following error occurs:The required instance of this module didn't exist. Module deleted. But it doesn't actually delete. I could go back in and manually delete the empty modules, but why does this still occur? Same bug or different one?

I get this problem with version 1.8.5. But the biggest problemn is not that the icons of non-existing modules appear, but that thsese modules have not been created by the restore !
I did not find any issue about this : the restore stops with no error message. This problem is reported by several users in "Using Moodle" forum and in "Assistance Technique" forum of course "Moodle en Français" :
See http://moodle.org/mod/forum/discuss.php?d=121608#p554771
Should I create a new (related ?) issue ?

Frédéric Hoogstoel
added a comment - 25/Jun/09 5:43 PM Hi !
I get this problem with version 1.8.5. But the biggest problemn is not that the icons of non-existing modules appear, but that thsese modules have not been created by the restore !
I did not find any issue about this : the restore stops with no error message. This problem is reported by several users in "Using Moodle" forum and in "Assistance Technique" forum of course "Moodle en Français" :
See http://moodle.org/mod/forum/discuss.php?d=121608#p554771
Should I create a new (related ?) issue ?
Thank you.