Moodle
  1. Moodle
  2. MDL-27156

File System Repository files limited by PHP upload_max_filesize limits

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.3
    • Component/s: Repositories
    • Labels:
    • Environment:
      Ubuntu/10.10; PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch; Apache/2.2.16
    • Testing Instructions:
      Hide

      Set these PHP settings in your php.in as follows: upload_max_filesize=2M, post_max_size=8M

      For this test you'll need a teacher and your admin user.

      Check your site's maximum uploaded file size. This is a site setting called "maxbytes". Set maxbytes to 2MB.

      Also set the course setting "Maximum upload size" to 2MB.

      You'll need a course backup. Check the file size and make sure that it is bigger than 10MB.

      As admin go to course admin > users > permissions > check permissions and check "moodle/course:ignorefilesizelimits" for a teacher. The teacher should NOT have moodle/course:ignorefilesizelimits.

      File system repository set up
      1. create a directory at moodledata/repository/examplerepository then set up a file system repository using that directory by going to: Site administration > Plugins > Repositories > Manage repositories > File System > Settings > Create a Repository Instance
      2. Outside of Moodle copy your course backup into the repository directory.

      As a teacher go into a course and do a restore into a new course. Select the course backup from the file repo.
      You should get an error about the file being too big.

      As admin give teacher moodle/course:ignorefilesizelimits in the course.
      Teacher should now be able to select the backup file and proceed with the restore.

      Additional testing.

      As any user but admin go to My private files.
      You should see something like "Maximum size for newfiles: 2MB - drag and drop available" near the top right of the file manager.

      As admin you should see something like "Maximum size for new files: -1 bytes - drag and drop available"
      As admin drag the course backup into your private files. You should get an error message about PHP.
      As admin click "Add..." and add add the course backup from your file repository. It should succeed.

      Show
      Set these PHP settings in your php.in as follows: upload_max_filesize=2M, post_max_size=8M For this test you'll need a teacher and your admin user. Check your site's maximum uploaded file size. This is a site setting called "maxbytes". Set maxbytes to 2MB. Also set the course setting "Maximum upload size" to 2MB. You'll need a course backup. Check the file size and make sure that it is bigger than 10MB. As admin go to course admin > users > permissions > check permissions and check "moodle/course:ignorefilesizelimits" for a teacher. The teacher should NOT have moodle/course:ignorefilesizelimits. File system repository set up 1. create a directory at moodledata/repository/examplerepository then set up a file system repository using that directory by going to: Site administration > Plugins > Repositories > Manage repositories > File System > Settings > Create a Repository Instance 2. Outside of Moodle copy your course backup into the repository directory. As a teacher go into a course and do a restore into a new course. Select the course backup from the file repo. You should get an error about the file being too big. As admin give teacher moodle/course:ignorefilesizelimits in the course. Teacher should now be able to select the backup file and proceed with the restore. Additional testing. As any user but admin go to My private files. You should see something like "Maximum size for newfiles: 2MB - drag and drop available" near the top right of the file manager. As admin you should see something like "Maximum size for new files: -1 bytes - drag and drop available" As admin drag the course backup into your private files. You should get an error message about PHP. As admin click "Add..." and add add the course backup from your file repository. It should succeed.
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull Master Branch:
      MDL-27156_part2
    • Rank:
      16809

      Description

      Files in the file system repository should not be limited by the PHP max file size.

      Steps:

      1. Setup file system repository in the moodledata/repository/examplerepository and enable the folder in: Site administration > Plugins > Repositories > Manage repositories > File System > Settings > Create a Repository Instance
      2. Copy a file to the repository using the file system that is larger than the PHP upload_max_file_size setting
      3. Create a new Page in a Course
      4. Attempt to link to the file from the Page using the File Picker

      Expected result:

      • Link to the file from the file system repository is created in the page

      Actual result:

      • File is apparently bigger than max file size

      This problem has been discussed in the forum, with workarounds requiring access to either .htaccess, php.ini, or a non-moodle file hosting site. http://moodle.org/mod/forum/discuss.php?d=166497 http://moodle.org/mod/forum/discuss.php?d=158886

      In my testing, the PHP max file size upload is 2MB and the PHP post max size is 8MB (ie., upload_max_filesize=2M and the post_max_size=8M)

      Any files larger than 2MB fail to be included from the file system repository, even though they are already on the file system and shouldn't in principle be limited to the PHP upload or post limits.

      The applicable lines in code are:

      repository/filepicker.php;96:
      $moodle_maxbytes = get_max_upload_file_size();
      repository/repository_ajax.php;86:
      $moodle_maxbytes = get_max_upload_file_size();

      If the user interface repository file pickers do not assume that all file transfers need to go through the PHP upload routine, then the file system repository links should succeed regardless of upload_max_filesize.

        Issue Links

          Activity

            People

            • Votes:
              65 Vote for this issue
              Watchers:
              26 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: