Description
saveLinks(XWikiDocument, XWikiContext, boolean) use save hibernate Session than calling saveXWikiDoc(XWikiDocument, XWikiContext, boolean) to render. But when main wiki's XWiki.XWikiPreferences is not already in the cache when we save sub wiki page, it try to get main wiki XWikiPreferences and get "new document" that is store in the cache and corrupt all that use it next.
This cas is very rare in current user cases but it appends for exemple in XE when creating sub wiki and import xar in this.