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

XWikiDocument.clone(true) doesn't clone properly the attachments

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.3-milestone-1
    • 3.1
    • Old Core
    • None
    • Unknown

    Description

      To reproduce and see the side effects of this issue, you can use the following code:

      have an XWikiDocument with attachments (from a Document.getDoc(), for example).

      XWikiDocument copiedDoc = docWithAttachments.copyDocument(copiedDocReference);
      // now all attachments of copiedDoc have content dirty true
      Document copiedApiDoc = new Document(copiedApiDoc);
      XWikiDocument sameCopiedDoc = copiedApiDoc.getDoc()
      
      

      in sameCopiedDoc all attachments have content dirty false, because Document.getDoc() uses clone which hits this bug.

      When trying to save Document, attachments will not be saved because Document.save() uses getDoc() at some point and all attachments are returned with content dirty false so no need to save.

      This is because of the 'clone' constructor at https://github.com/xwiki/xwiki-platform/commit/fe1209643b6d1638a5bb19336cc3c81b5bb487a8#L1R57 which does not clone the content dirty flag.

      Attachments

        Activity

          People

            calebjamesdelisle CalebJamesDeLisle
            lucaa Anca Luca
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: