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

Temporary objects are persisted in the document cache

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 2.2 RC1
    • 2.2 M2
    • {Unused} APIs
    • None
    • Trivial

    Description

      Calling $doc.getObject('some.classname', true) without saving the document will still show the new object in consecutive requests for that document, as long as the document is still in the cache.

      This is caused by the fact that the second parameter (create) sometimes causes changes to the document, although the method name suggests a simple getter without side effects. Checking if the object was there in the first place or was created as a result of this method call is costly, so I'd suggest to simply play it safe and always clone the document, especially since the method is supposed to make changes.

      I call them "temporary objects" because calling getObject without saving the document usually means that we need a fake object for displaying a create form with the configured display style.

      Attachments

        Activity

          People

            sdumitriu Sergiu Dumitriu
            sdumitriu Sergiu Dumitriu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: