Details
-
Bug
-
Resolution: Fixed
-
Minor
-
2.2 M2
-
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.