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

Add configuration option for how long to keep drafts before removing them

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.2.1
    • Files API
    • MOODLE_22_STABLE
    • MDL-31645-master-1
    • Easy
    • Hide
      • Turn Editing on
      • Add a new file
      • Upload your new file
      • Don't actually save
      • Break out your database and find your file. A query such as the following should suffice for most testing:

        SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files ORDER BY id DESC LIMIT 2;

      • Make a note of the ids you get
      • run the cron (either CLI or web)
        • Ensure that you get the 'Deleting old draft files... done.' message
        • Check that your draftfile is still present:

          SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files WHERE id IN (140, 141);

      • open your config.php and set the filepurgeage to something a long way away (e.g. a month):

        $CFG->filepurgeage = 60 * 60 * 24 * 31;

      • run the cron (either CLI or web)
        • Ensure that you get the 'Deleting old draft files... done.' message
        • Check that your draftfile is still present:

          SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files WHERE id IN (140, 141);

      • open your config.php and set the filepurgeage to something very soon (e.g. 30 seconds):

        $CFG->filepurgeage = 30;

      • run the cron (either CLI or web)
        • Ensure that you get the 'Deleting old draft files... done.' message
        • Check that your draft has now gone

          SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files WHERE id IN (140, 141);

      Show
      Turn Editing on Add a new file Upload your new file Don't actually save Break out your database and find your file. A query such as the following should suffice for most testing: SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files ORDER BY id DESC LIMIT 2; Make a note of the ids you get run the cron (either CLI or web) Ensure that you get the 'Deleting old draft files... done.' message Check that your draftfile is still present: SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files WHERE id IN (140, 141); open your config.php and set the filepurgeage to something a long way away (e.g. a month): $CFG->filepurgeage = 60 * 60 * 24 * 31; run the cron (either CLI or web) Ensure that you get the 'Deleting old draft files... done.' message Check that your draftfile is still present: SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files WHERE id IN (140, 141); open your config.php and set the filepurgeage to something very soon (e.g. 30 seconds): $CFG->filepurgeage = 30; run the cron (either CLI or web) Ensure that you get the 'Deleting old draft files... done.' message Check that your draft has now gone SELECT id, component, filearea, filepath, filename, timecreated, timemodified FROM mdl_files WHERE id IN (140, 141);

      After a spate of users who failed to click the 'Save Changes' button when uploading coursework, we've had to delve into the database to determine whether each user in question uploaded a file on the assignment page.

      Alas, most of these didn't notice that they hadn't got a grade until around about 30 days what with the joys of Christmas, etc. As a result, we've resorted to restoring database backups to determine whether the user had uploaded files.

      Because of all of this, we've followed the advice in lib/filestorage/file_storage.php's file_storage::cron() function to set:

      // if you want to disable purging of trash put $CFG->fileslastcleanup=time(); into config.php

      However, it would be useful to be able to override the default age before removal. At present, this is hardcoded to four days.

      I propose making it possible to set this (probably though config.php rather than in the UI) to allow us to keep drafts for longer but still ultimately purge them. This won't affect most users, but will ensure that those of us who have the misfortune to investigate these kinds of things don't have quite such a hard time.

            Unassigned Unassigned
            dobedobedoh Andrew Lyons
            Votes:
            6 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.