Issue Details (XML | Word | Printable)

Key: MDL-19281
Type: Improvement Improvement
Status: Open Open
Priority: Critical Critical
Assignee: moodle.com
Reporter: Valery Fremaux
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Custom course formats cannot cleanup data on course deletion because not implemented

Created: 22/May/09 08:56 PM   Updated: 22/May/09 08:56 PM
Return to search
Component/s: Course
Affects Version/s: 1.9.5, 1.9.6, 2.0
Fix Version/s: None

Participants: moodle.com and Valery Fremaux
Security Level: None
Affected Branches: MOODLE_19_STABLE, MOODLE_20_STABLE


 Description  « Hide
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.
  

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
No changes have yet been made on this issue.