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

XWiki#CopyDocument() may wrongly create a revision and overwrite modification date when used with filesystem attachments

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 9.10-rc-1
    • 8.4.4, 9.1
    • Old Core
    • None
    • Unknown
    • N/A
    • N/A

    Description

      The issue only happen when using the Filesystem attachement versioning and the XWiki#CopyDocument() is used with resetCreationData set to false.
      With this argument, the copied document is supposed to be identical to the original document without any trace of the copy action, exact same dates and history.
      In the process of the FilesystemAttachmentVersioningStore, the XWikiAttachment#setDoc() method is called (see https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/main/java/org/xwiki/store/legacy/doc/internal/ListAttachmentArchive.java#L331) causing the XWikiDocument#setMetadataDirty(true) to called on the copied document (see https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiAttachment.java#L453).

      Since the metadata dirty get set, the save of the copy cause the modification date to be changed and a new revision to be created.

      $xcontext.getXWiki().copyDocument($sourceRef, $targetRef, $NULL, false, true, false, $xcontext.context)
      

      Attachments

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              softec Denis Gervalle
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: