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

Overwriting files does not observe the "alias" attribute always...

    Details

    • Testing Instructions:
      Hide

      Sorry for the amount of tests but there is a lot of code duplication and I want to make sure that all options work.

      To test under 23_STABLE, 24_STABLE and 25_STABLE!

      Test 1. Basic overwrite a file

      1. Edit any page with filemanager (for example Private files)
      2. Add a file from repository (Server file, Dropbox, etc) as a copy
      3. Add the same file again but as a shortcut
      4. Make sure file looks like shortcut
      5. Save file area and return to editing
      6. Make sure file is a shortcut

      Repeat the same test but save filearea after #2

      Test 2. Renaming and moving source file

      1. Add file to private files, create a shortcut to it from somewhere else (for example file resource on frontpage)
      2. Edit private files and rename the source file
      3. Make sure it no longer looks like a source
      4. Make sure the shortcut is converted to the copy

      Repeat the same with moving file to the folder or renaming containing folder

      Test 3. Overwrite vs Delete+replace

      1. Add five files to private files, create shortcuts to all of them from somewhere else
      2. Edit private files. Overwrite 1st file by uploading, overwrite 2nd file by picking it from any repository (as a copy), overwrite 3rd file using drag&drop.
      3. Remove the 4th file and upload another file with the same name as removed
      4. Rename the 5th file twice restoring original name
      5. Make sure first 3 files are still listed as sources and 4th & 5th are not
      6. Save file area and open it for editing again
      7. Make sure first 3 files are listed as sources and 4th & 5th are not
      8. Make sure shortcuts to the first 3 files are updated (new thumbnail, content is correct, ...)

      Test 4. Non-JS filemanager

      1. Disable Javascript
      2. Edit any form containing filearea (for example private files) and make sure basic operations work (look at moving and deleting the files). There is no support for file references and no possibility to overwrite a file in non-js filemanager.
      3. If something is not working as expected please make sure it is a regression from this issue before failing it

      Test 5. Attemp to create double reference

      1. Add a file to private files and create a shortcut to it from somewhere else
      2. Edit private files again, try to overwrite the source with a shortcut (like in Test 1 but with when file is a source of a shortcut)
      3. Make sure the popup appears and action is not possible
      4. Add another file to private files, save it and return to editing
      5. In another window create a shortcut to this file, save.
      6. Return to window with private files and overwrite the file with shortcut (no message appears because in this case we don't know that references exist)
      7. Save private files, make sure the exception is thrown and file is not substituted with shortcut

      Test 6. Unzipping

      1. Add archive file to the private files (must contain subfolders)
      2. Extract (unzip) archive file and make sure that files are extracted properly
      3. Save private files
      4. Create a shortcut to one of the extracted files from other filearea, save it
      5. Edit private files, overwrite the source file, save private files, make sure shortcut is updated
      6. Delete or modify some other extracted files, add more files to extracted subfolders, save private files
      7. Extract archive again and make sure everything is overwritten correctly, shortcut is still a shortcut and it is updated

      Note: there is no warning when files get overwritten during unzip. It is not related to this issue.

      Test 7. Overwriting file by another user

      1. Use any filearea where several users have access to (for example Folder resource in a course with several teachers)
      2. Upload a file as user1, save filearea (use the file here that has never previously been used)
      3. Open any textarea or filemanager, open filepicker and make sure user1 can see this file in his recent files
      4. Login as user2, upload (by overwriting) different file with the same name, save filearea
      5. Make sure user2 can see the new file in his recent files
      6. Make sure user1 can not see any of those two files in his recent files
      Show
      Sorry for the amount of tests but there is a lot of code duplication and I want to make sure that all options work. To test under 23_STABLE, 24_STABLE and 25_STABLE! Test 1. Basic overwrite a file Edit any page with filemanager (for example Private files) Add a file from repository (Server file, Dropbox, etc) as a copy Add the same file again but as a shortcut Make sure file looks like shortcut Save file area and return to editing Make sure file is a shortcut Repeat the same test but save filearea after #2 Test 2. Renaming and moving source file Add file to private files, create a shortcut to it from somewhere else (for example file resource on frontpage) Edit private files and rename the source file Make sure it no longer looks like a source Make sure the shortcut is converted to the copy Repeat the same with moving file to the folder or renaming containing folder Test 3. Overwrite vs Delete+replace Add five files to private files, create shortcuts to all of them from somewhere else Edit private files. Overwrite 1st file by uploading, overwrite 2nd file by picking it from any repository (as a copy), overwrite 3rd file using drag&drop. Remove the 4th file and upload another file with the same name as removed Rename the 5th file twice restoring original name Make sure first 3 files are still listed as sources and 4th & 5th are not Save file area and open it for editing again Make sure first 3 files are listed as sources and 4th & 5th are not Make sure shortcuts to the first 3 files are updated (new thumbnail, content is correct, ...) Test 4. Non-JS filemanager Disable Javascript Edit any form containing filearea (for example private files) and make sure basic operations work (look at moving and deleting the files). There is no support for file references and no possibility to overwrite a file in non-js filemanager. If something is not working as expected please make sure it is a regression from this issue before failing it Test 5. Attemp to create double reference Add a file to private files and create a shortcut to it from somewhere else Edit private files again, try to overwrite the source with a shortcut (like in Test 1 but with when file is a source of a shortcut) Make sure the popup appears and action is not possible Add another file to private files, save it and return to editing In another window create a shortcut to this file, save. Return to window with private files and overwrite the file with shortcut (no message appears because in this case we don't know that references exist) Save private files, make sure the exception is thrown and file is not substituted with shortcut Test 6. Unzipping Add archive file to the private files (must contain subfolders) Extract (unzip) archive file and make sure that files are extracted properly Save private files Create a shortcut to one of the extracted files from other filearea, save it Edit private files, overwrite the source file, save private files, make sure shortcut is updated Delete or modify some other extracted files, add more files to extracted subfolders, save private files Extract archive again and make sure everything is overwritten correctly, shortcut is still a shortcut and it is updated Note: there is no warning when files get overwritten during unzip. It is not related to this issue. Test 7. Overwriting file by another user Use any filearea where several users have access to (for example Folder resource in a course with several teachers) Upload a file as user1, save filearea (use the file here that has never previously been used) Open any textarea or filemanager, open filepicker and make sure user1 can see this file in his recent files Login as user2, upload (by overwriting) different file with the same name, save filearea Make sure user2 can see the new file in his recent files Make sure user1 can not see any of those two files in his recent files
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull Master Branch:
      wip-MDL-39177-master

      Description

      While testing some other repository issues I came to this situation:

      1) with some repository defined (mine was a filesystem system-wide repo).
      2) got to any area accepting aliases (user private files is ok).
      3) and add the file xxxx.yyy (making a copy of the file)
      4) then add again the same file (now creating an alias)
      5) The overwrite/rename dialog will be shown.
      6) Select "overwrite", so your second added file wins.
      7) Save changes to ensure there isn't any refresh visual glitch.
      8) The file xxxx.yyy file should be an alias. It's a copied file.

      Note that the opposite also happens, first alias, then copy and overwrite should lead to copy, but it remains as alias.

      Somehow the overwrite feature is now alias-aware.

      No problems detected when renaming is selected instead of overwrite.

      Ciao


      The complete list of problems:

      1. Filemanager was not refreshed after overwriting a file (this is issue MDL-33719).
      2. The 'original' attribute of draftfile was lost when file was overwritten, therefore the list of shortcuts no longer appeared (but it was not obvious becase filemanager was not refreshed).
      3. The 'original' attribute of draftfile was ignored when draftarea was saved. Which sort of compensated #2 but if file was deleted and replaced it was treated the same as if it was overwritten (even though filemanger UI distinguished those cases)
      4. When saving filearea the maxbytes check did not apply to the updated files
      5. It was not possible to replace the file with a reference (actually this is what the original issue text was about). So after it has became possible we need to make sure that double references are not created.
      6. When files are unzipped, they are overwritten without warning, source was not specified, original was lost.
      7. When one user overwrites the file of another user, the files.userid field was not updated and the new file appeared in the 'Recent file' of the wrong user

      To add to this: there is/was a lot of code duplication and overwriting files when picking from repository, uploading, drag&drop and/or unzipping are treated differently. JS and non-JS filemanager treat(ed) rename/move also differently.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    8/Jul/13