Directly modifying the XWikiDocument from the document cache is a very bad practice because it potentially impacts all threads and it could corrupt the cache if the XWikiDocument us never saved. Instead one is supposed to clone a XWikiDocument before modifying it. The idea is to warn about any write on a cached XWikiDocument with a stack trace to find the source of that writing. See https://forum.xwiki.org/t/make-sure-to-always-return-a-clean-document-from-the-cache/15562/1 for the related proposal. |