Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-24685

When the move of an attachment fails, a redirection to an attachment that was never created is left behind

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 18.7.0-rc-1
    • 14.0
    • Attachments
    • None
    • Integration
    • Unknown
    • N/A
    • N/A

    Description

      When an attachment is moved to another page with Create a redirection checked and the save of the target page fails, the move is rolled back — the attachment is put back on the source page — but the redirection object that was created on the source page is not removed. The source page is therefore left with a redirection pointing to an attachment that was never created.

      Since a redirection is resolved before the attachment is served, and the resolution only checks that a redirection object exists (not that the attachment it points to exists), the attachment restored by the rollback also becomes unreachable: downloading it from the source page redirects to the target attachment, which does not exist.

      Steps to reproduce:

      1. Create a page A holding an attachment file.txt, and a page B.
      2. Arrange for the save of B to fail (a storage error, for instance) — this is the hard part, the problem is not reachable through the UI without a failing save.
      3. From A, move file.txt to B, keeping Create a redirection checked.

      Expected result:

      • Once the move has been rolled back, A holds file.txt and no redirection object.

      Actual result:

      • A holds file.txt again (the rollback itself works), but it also holds a RedirectAttachmentClass object pointing to file.txt in B, which was never created.
      • Downloading file.txt from A redirects to the non-existent attachment in B instead of serving the restored attachment.

      Notes:

      • Only the move-to-another-page path is affected. Renaming an attachment inside the same page performs a single save and has no rollback.
      • MoveAttachmentJob#initializeAutoRedirection adds the object to the source document before the first save, and the rollback branch of MoveAttachmentJob#transactionalMove restores the attachment but does not remove that object.
      • Present since the move-attachment feature was introduced in 14.0 (XWIKI-1657).
      • The current behaviour is pinned by MoveAttachmentJobTest#processTargetSaveFail, added by XWIKI-24680, so fixing this requires updating that test.

      Attachments

        Issue Links

          Activity

            People

              alyserry Aly Serry
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: