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

Error in mod_folder: Big files deleted when editing teachers update resource with global maxbytes lower

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As the admin change the site maxbytes setting (Site administration > Security > Site policies) Maximum uploaded file size to something low.
      2. Create a folder resource.
      3. Add a folder to the filepicker.
      4. Add some large files as the administrator.
      5. Log in as a teacher (editingteacher) and edit the folder resource. Only change the name of the folder (in the filepicker). Don't change the files.
      6. Save the changes.
      7. The large files should still be present and not deleted.
      Show
      As the admin change the site maxbytes setting (Site administration > Security > Site policies) Maximum uploaded file size to something low. Create a folder resource. Add a folder to the filepicker. Add some large files as the administrator. Log in as a teacher (editingteacher) and edit the folder resource. Only change the name of the folder (in the filepicker). Don't change the files. Save the changes. The large files should still be present and not deleted.
    • Affected Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-52100-master

      Description

      Reproduction steps

      1. As the admin change the site maxbytes setting (Site administration > Security > Site policies) Maximum uploaded file size to something low.
      2. Create a folder resource. Add a folder to the filepicker. Add some large files as the administrator.
      3. Log in as a teacher (editingteacher) and edit the folder resource. Only change the name of the folder. Don't change the files.
      4. Observe that the large files are now gone.

      The following line checks to see if the file size is larger than the max bytes for that user and if it is then the new hash is not created, hence the existing files are removed. https://github.com/moodle/moodle/blob/master/lib/filelib.php#L915

      Problem description:
      Big files (bigger than maxbytes defined) are deleted on a "visible" folder when an editingteachers role save the resource.
      We upload into a "mod_folder" resource 2 files bigger than platform limit (u can increase / decrease limit for upload with teacher role), and as editingteacher role (no admin) edit folder and save them, all files bigger than maxsize variable disappear of the folder. If we do the same process as admin, no delete files.

      Environment:

      • Moodle 2.9.5 and 3.0.3 (also ocurred in previous versions).
      • Linux RHEL
      • PHP 5.5.21
      • Postgres 9.3.4
      • Moodle maxbytes variable: 5MB

        Attachments

          Activity

            People

            • Votes:
              9 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jan/18