Details
-
Bug
-
Resolution: Fixed
-
Major
-
3.1
-
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.