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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: DEV backlog
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      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);
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-31645-master-1

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                6 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated: