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

Make sure to always return a clean document from the cache

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • 16.9.0-rc-1
    • 16.7.1
    • Old Core
    • None
    • Unknown

    Description

      It's easy to mess with the document in the cache for the other threads by modifying it without cloning it. Since that's a very common mistake, we should ideally find a way to fix that.

      I can think of two possibilities, in XWikiCacheStore#loadXWikiDoc:
      1. always return a cloned version of the XWikiDocument
      2. before returning the XWikiDocument, check if it was modified (XWikiDocument#isMetadataDirty) and reload it from the database if that's the case

      The good thing with 1. is that it's safe, but it makes readonly uses case much slower, and it will clone the XWikiDocument twice in most (currently proper) cases. So I feel the best is 2., but we should also properly fix XWIKI-22510 and make extra sure that any modification leads to a dirty metadata flag set to true (for example, it's not the case right now for some plumbing modifications like the original document, and it's needed to cover use cases like XWIKI-22511).

      Attachments

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              tmortagne Thomas Mortagne
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: