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

Wiki attachments are deleted by Atto

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.8.5
    • Fix Version/s: None
    • Labels:
      None
    • Affected Branches:
      MOODLE_28_STABLE

      Description

      I observed the following issue in Moodle 2.8.5:
      If a new wiki page is created, files are added to attachment area and content is created using Atto before saving the page, the newly uploaded attachment files are deleted.

      Steps to reproduce:
      1. Create a new empty wiki page.
      2. Go to "Files" tab and add new attachment files
      3. Submit changes to files
      4. Click on "Edit" tab without viewing the page before
      5. Enter content using Atto
      6. Submit edit page
      7. The newly added attachments have been deleted!

      As I have figured out so far, this problem arises in Atto's autosave function which also saves the draft files area. When trying to restore the saved data, Atto merges the saved draft area with the newly created one. However, all files that have been newly added are deleted.

      I have observed the following scenario:

      • When a new wiki page is created, Moodle initialises a new draft file area which contains all attachment files.
      • Atto creates a new autosave record pointing to the newly created draft file area.
      • When files are added, Moodle creates another draft file area and copies newly added files to attachment area.
      • When returning to Atto, the autosave record is retrieved from DB. Atto tries to restore all saved content.
      • The draft file area from the autosave record is merged with the other draft area.
      • Newly added files are only in the destination area but not in the source area. => Moodle interprets data that is only in destination area as "to be deleted" and therefore deletes newly added files from draft area.
      • After submitting the content created in Atto, Moodle merges the draft area with the attachments area. As the newly added files have already been deleted from draft area, these files only exist in the attachments area.
      • Hence the new files are again considered as "to be deleted" and therefore are also deleted from attachments area.

      I assume this is caused by function file_save_draft_area_files() from lib/filelib.php which interprets all files existing only in destination file area as "to be deleted". However, for merging two draft file areas, there should be a function that copies all files from source to destination except for all files that already exist in destination area.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            senikuro Nils Kurowsky
            Participants:
            Component watchers:
            Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: