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

Filemanager: cannot manage files when there are folders

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create an assignment.
      2. Make sure the submission types are file submissions.
      3. Change the accepted file types to "Image files".
      4. Log in as a student and enter the assignment.
      5. Create a folder and upload an image in that folder.
      6. Create a second folder and upload an image in that folder.
      7. Create a folder in one of the other folders and upload an image in that folder.
      8. Save the assignment and check that there is no warning about the type of file uploaded.
      9. Edit the assignment and try and load a file that is not an image into any of the folders that you have created.
      10. Check that a message is shown saying that this type of file can not be accepted.
      Show
      Create an assignment. Make sure the submission types are file submissions. Change the accepted file types to "Image files". Log in as a student and enter the assignment. Create a folder and upload an image in that folder. Create a second folder and upload an image in that folder. Create a folder in one of the other folders and upload an image in that folder. Save the assignment and check that there is no warning about the type of file uploaded. Edit the assignment and try and load a file that is not an image into any of the folders that you have created. Check that a message is shown saying that this type of file can not be accepted.
    • Affected Branches:
      MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull from Repository:
    • Pull 3.4 Branch:
    • Pull 3.5 Branch:
    • Pull Master Branch:
      MDL-62849-master

      Description

      • When a filemanager is configured to allow subdirs and restrictions are added to the accepted file types, the filemanager does not permit to add or manage files with folders.
      • we are working on a plugin that uses this functionality and it stopped working when we upgraded to Moodle 3.4, I included the plugin in a .zip file.

      STEPS TO REPLICATE WITH THE PLUGIN "Theme assets":

      1. Go to Site administration > Appearance > Theme assets
      2. Click the create a folder button.
      3. Provide a name for the new folder and click the Create folder button.
      4. Open the new folder.
      5. Upload a file that is of an accepted file type such as .png.
      6. Click the Save changes button.

      OBSERVED BEHAVIOR:
      Receive error stating, "Some files (.) cannot be uploaded. Only file types web_file, web_image are allowed." If you navigate away from the theme assets tool and return to the tool you will observe that the new folder and file were not saved.

      EXPECTED BEHAVIOR:
      New folder and file are saved without any errors.

      FURTHER INVESTIGATION:

      • Using a filemanager I created a folder (Folder 10) and uploaded an image inside it (File 2), I also uploaded an image (File 1) at the same "level" of the folder.
      • then I included "print_object($draftfiles)" in the function "validateSubmitValue" on line 337, the result that I obtained was the following: 
      • stdClass Object
        (
            [path] => Array
                (
                    [0] => Array
                        (
                            [name] => Files
                            [path] => /
                        )
         
                )
         
            [itemid] => 480128757
            [list] => Array
                (
                    [0] => stdClass Object
                        (
                            [filename] => .
                            [filepath] => /Folder 10/
                            [fullname] => Folder 10
                            [size] => 
                            [filesize] => 0
                            [sortorder] => 0
                            [author] => 
                            [license] => 
                            [datemodified] => 1530632387
                            [datecreated] => 1530632387
                            [isref] => 
                            [icon] => http://moodle.test/theme/image.php/snap/core/1530317540/f/folder
                            [type] => folder
                            [thumbnail] => http://moodle.test/theme/image.php/snap/core/1530317540/f/folder
                        )
         
                    [1] => stdClass Object
                        (
                            [filename] => File 1.png
                            [filepath] => /
                            [fullname] => File 1.png
                            [size] => 125063
                            [filesize] => 122.1KB
                            [sortorder] => 0
                            [author] => Moodlerooms Support
                            [license] => allrightsreserved
                            [datemodified] => 1530632398
                            [datecreated] => 1530632398
                            [isref] => 
                            [mimetype] => Image (PNG)
                            [type] => file
                            [url] => http://moodle.test/draftfile.php/2425/user/draft/480128757/File%201.png
                            [icon] => http://moodle.test/theme/image.php/snap/core/1530317540/f/png
                            [thumbnail] => http://moodle.test/theme/image.php/snap/core/1530317540/f/png
                            [status] => 0
                            [realthumbnail] => http://moodle.test/draftfile.php/2425/user/draft/480128757/File%201.png?preview=thumb&oid=1530632398
                            [realicon] => http://moodle.test/draftfile.php/2425/user/draft/480128757/File%201.png?preview=tinyicon&oid=1530632398
                            [image_width] => 3316
                            [image_height] => 1544
                        )
         
                )
         
        )

      • It seems that the function "file_get_drafarea_files" is not returning the files inside the folder.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Sep/18