Details
-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
2.3
-
None
-
store save original document event listeners
-
Unknown
-
Description
When saving an XWiki document in the XWikiStore, we set the original document to be a clone of the document that was just been saved. see: https://fisheye2.atlassian.com/browse/xwiki/platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java?r=HEAD#l648
... and then, when needing to notify event listeners, we do a hack like this: https://fisheye2.atlassian.com/browse/xwiki/platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java?r=HEAD#l1415
The problem appears when trying to save the same document from an event listener that is listening to DocumentUpdateEvent events.
When saving the document from the event listener, the save gets overridden by the "magic" done at https://fisheye2.atlassian.com/browse/xwiki/platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java?r=HEAD#l1468
In the following use case:
saveDocument1 changeListener1 saveDocument2 changeListener2 (does nothing) end saveDocument2 end changeListener1 end saveDocument1 <-- sets the original document to something other than what 'saveDocument2' intended.
... and the loop could be deeper.
Next time this use case occurs, changeListener will receive a different original document than expected.
As a suggestion, this could [?] be fixed by making the clone() call at the beginning of the store.saveXWikiDocument() instead of at the end, when it's already modified, this way avoiding all the code done at https://fisheye2.atlassian.com/browse/xwiki/platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java?r=HEAD#l648 to re-establish the proper original document and allowing DocumentUpdateEvent listeners to correctly modify the document.
Attachments
Issue Links
- blocks
-
SCRIBO-42 Show dirty state on the configuration page when Apply needs to be pressed.
- Closed