Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-19281

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.5, 1.9.6, 2.0
    • Fix Version/s: 2.0
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              skodak Petr Skoda
              Reporter:
              vf Valery Fremaux
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                24/Nov/10