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

filemanager UI treats maxfiles=0 as unlimited, inconsistent with back end

    Details

    • Testing Instructions:
      Hide
      • Purge caches (Moodle and browser) to ensure that you're not using any cached JS
      • Change the maxfiles setting of a file manager (such as that in /user/files.php - or /user/filesedit.php in 2.2) to 0
      • Confirm that the file manager does not display the "Add..." button or allow files to be dragged in (dragging in files should result in the maxfilesreached message being displayed)
      • Change the maxfiles setting of the file manager to 1
      • Confirm that the file manager allows one (and only one) file to be chosen / dragged in, and that the chosen file is saved when the form is submitted
      • Change the maxfiles setting of the file manager to 2
      • Confirm that the file manager allows up to two files (but no more) to be chosen / dragged in, and that the chosen files are saved when the form is submitted
      • Change the maxfiles setting of the file manager to -1
      • Confirm that the file manager no longer lists a maximum number of files, that you can choose / drag in several files, and that the chosen file are saved when the form is submitted
      • Set the maxfiles setting of the file manager back to its original value

      NOTE: The above steps which start "Change the maxfiles setting" (and the last step) involve changing the code - no core settings UI (as far as I'm aware) provides all applicable options.

      Show
      Purge caches (Moodle and browser) to ensure that you're not using any cached JS Change the maxfiles setting of a file manager (such as that in /user/files.php - or /user/filesedit.php in 2.2) to 0 Confirm that the file manager does not display the "Add..." button or allow files to be dragged in (dragging in files should result in the maxfilesreached message being displayed) Change the maxfiles setting of the file manager to 1 Confirm that the file manager allows one (and only one) file to be chosen / dragged in, and that the chosen file is saved when the form is submitted Change the maxfiles setting of the file manager to 2 Confirm that the file manager allows up to two files (but no more) to be chosen / dragged in, and that the chosen files are saved when the form is submitted Change the maxfiles setting of the file manager to -1 Confirm that the file manager no longer lists a maximum number of files, that you can choose / drag in several files, and that the chosen file are saved when the form is submitted Set the maxfiles setting of the file manager back to its original value NOTE: The above steps which start "Change the maxfiles setting" (and the last step) involve changing the code - no core settings UI (as far as I'm aware) provides all applicable options.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-29835_master

      Description

      If you want a filemanager to accept any number of files (i.e. no limit to the number), the maxfiles parameter is treated inconsistently by the UI and the back end. If you set maxfiles to -1, both the UI and back end treat this as "no limit" and let you upload as many files as you like - but if you set it to 0 instead, the (JavaScript) UI allows any number of files to be added but the back end (i.e. file_postupdate_standard_filemanager()) will treat it as literally a limit of 0 files - and therefore won't add any files. It doesn't trigger a warning/error message, though - thereby giving the impression that something is broken.

      Setting maxfiles to 0 can therefore lead to a lot of head-scratching and agony before you realise you should have set it to -1. If the UI properly treated zero as zero, it would prevent uploading of any files (not show the "Add..." button) - which would prevent confusion, as it would immediately become apparent that zero does, in fact, mean zero. It might not be quite so apparent that -1 is the answer, though - perhaps if EDITOR_UNLIMITED_FILES was renamed to something a little more generic, or another constant was added (MANAGER_UNLIMITED_FILES, perhaps?), it would be a little easier for developers to discover.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Mar/13