Details
Description
When working with custom course formats (e.g. flexipage among others) that need extra information to describe information relationship, there is no hooking from core that triggers a format scope course cleanup.
Flexipage has a page_delete_course() callback that is never called from delete_course() call nor subcalls.
Result of this is that format_page and format_page_items are not deleted, which has no influence on a single platform, but is critical when roaming content from a moodle to another. In that case will gohst pages rebind accidentally to a newly restored course, aggegating old content (though assumed is was deleted !) to the course.
The fix is very simple :
Index: moodlelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v
retrieving revision 1.960.2.127
diff -u -r1.960.2.127 moodlelib.php
— moodlelib.php 22 Apr 2009 08:39:33 -0000 1.960.2.127
+++ moodlelib.php 22 Jun 2009 12:29:46 -0000
@@ -3719,6 +3719,16 @@
}
}
+/// Clean up course format related things
+
+ $formatlib = $CFG->dirroot."/course/format/{$course->format}/lib.php";
+ if (file_exists($formatlib)){
+ include_once($formatlib);
+ $deletecourseformathook = $course->format.'_delete_course';
+ if (function_exists($deletecourseformathook)){
+ $deletecourseformathook($course->id);
+ }
+ }
/// Clean up metacourse stuff
This fix calls the <formatname>_delete_course($courseid) callback in the current format implementation for the delted course. Portable to 2.0 I guess.
Cheers.
Issue Links
| This issue has a non-specific relationship to: | ||||
| MDL-12077 | Add course delete hook for course formats |
|
|
|
+1 from me. Makes sense to you, Petr?