Details
-
Bug
-
Resolution: Fixed
-
Major
-
4.0-rc-1
-
save event update synthetic document
-
Unknown
-
N/A
-
N/A
-
Description
When trying to save an XWikiDocument instance that was created outside the API (thus, "synthetic"), like for example at XAR import (when each document is created from its XML representation), listeners to DocumentUpdat(ing/ed)Event will never be notified, even when a version of the imported document already exists in the database (overriding import).
This is because in the saveDocument method, we always create an originalDocument for XWikiDocuments that have none (synthetic documents), but we never set the isNew flag on this originalDocument. This means that, below in the code when originalDocument.isNew() is checked, it will always return true and always notify listeners of DocumentCreat(ing/ed)Event.
The right way would be that, when we create originalDocument for synthetic XWikiDocuments, we should also do:
originalDocument.setNew(exists(doc.getDocumentReference(), context))
However, it is quite costly to do an additional DB query, at each save.
Attachments
Issue Links
- relates to
-
XWIKI-7747 Right after a migration to 4.0, the current Annotations class is not updated and new annotations are not created properly
- Closed
-
XWIKI-7752 Importer save document with wrong original document
- Closed