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

Updating file/picture fields breaks references

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      test for picture and file fields

      1. Create a database activity with at least one file or picture field
      2. Insert an entry with a file or picture
      3. Create a file resource add the file or picture just added to the database as a Shortcut/Alias (through server files in file picker)
      4. Click edit on the database entry and save the entry without change anything
      5. Check if the file or picture in the file resource is still a Shortcut/Alias of the file in the database entry. Without the patch it is now be a standalone file and not a alias anymore.

      in addition for picture fields

      1. Edit the database entry, remove the picture and save the entry.
      2. Now the single and list view still try to display the image, but it can't be loaded because it doesn't exist anymore.
      Show
      test for picture and file fields Create a database activity with at least one file or picture field Insert an entry with a file or picture Create a file resource add the file or picture just added to the database as a Shortcut/Alias (through server files in file picker) Click edit on the database entry and save the entry without change anything Check if the file or picture in the file resource is still a Shortcut/Alias of the file in the database entry. Without the patch it is now be a standalone file and not a alias anymore. in addition for picture fields Edit the database entry, remove the picture and save the entry. Now the single and list view still try to display the image, but it can't be loaded because it doesn't exist anymore.
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      master-MDL-49750

      Description

      Updating a file or picture database field within a database activity breaks all intern file references to this file.
      This is due to the arbitrary "update" algorithm in the field.class.php files for this fields. Instead of updating the existing file the file will be deleted and recreated.

      I've implemented a patch that makes use of the file_save_draft_area_files() function to create/update/delete a file.
      Afterwards the data content will be updated. If the file was deleted the content is set to null. This is related to MDL-42349.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Nov/15