Details
-
Bug
-
Resolution: Fixed
-
Major
-
4.1.2
-
None
-
Trivial
-
N/A
-
N/A
-
Description
If you execute the following code:
{{groovy}} import com.xpn.xwiki.doc.XWikiDocument; def context = xcontext.getContext(); def backup = null; try { def targetDoc = xwiki.getDocument("Space.Page").getDoc(); backup = new HashMap<String, Object>(); XWikiDocument.backupContext(backup, context); targetDoc.setAsContextDoc(context); // ... } finally { if (backup != null) { println doc.getFullName(); XWikiDocument.restoreContext(backup, context); println doc.getFullName(); } } {{/groovy}}
the second printed full name is "Space.Page" instead of the current document. The reason is that XWikiDocument#restoreContext restores the context document after accessing the Velocity context and thus the script context (re)initialization triggered by the Velocity manager is done using the current context document.
Attachments
Issue Links
- relates to
-
XWIKI-8104 doc points to a different instance after calling doc.save()
- Closed