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

XWikiMessageTool does not distinguish between translations document bundles from different wikis in multiwiki mode

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • None
    • None
    • Old Core
    • Unknown
    • N/A
    • N/A

    Description

      The title is a bit technical, I didn't know how to explain it better as it could have multiple effects.

      Mainly, the problem is that in the XWikiMessageTool, the props cache (the cache of translations keys and values read from a document) is indexed on translations document id (see this line https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiMessageTool.java#L330 ) , which is local by design (see this line https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java#L547 ). If 2 documents have the same name but are from different wikis, the cache mistakenly believes that it's one and the same document and doesn't load the new one. This issue is very hard to reproduce because the documents need to also have the same date, since this properties cache is invalidated when the date of the new document is different than the date of the cached document. However, for xars in which documents have a fixed date, it's very easy to reproduce, since they will keep their date on import.

      For some reason though, this will not prevent pages from a wiki to be displayed properly translated after pages from another wiki have been displayed (the props cache might be invalidated between requests, I don't know).

      However, the way I reproduced this issue is the following:
      1/ create a page in a subwiki which uses translations from the subwiki, stored in a document called XWiki.Translations. Don't forget to set this document in the localisation bundle of the subwiki so that the page displays properly. I used velocity scripting to use translations ($msg.get)
      2/ in the main wiki, create a page that uses translations from the main wiki (stored in a document called XWiki.Translations – same, don't forget to put it in the localization bundle).
      3/ in this same page in the main wiki, display with velocity the rendered content of the document in the subwiki ($subdocument.getRenderedContent()), after setting the database ($context.setDatabase($subwiki)) and current document ($context.setDoc($subdocument.document)).
      4/ make sure to have the same date for the 2 translation bundle documents from the 2 wikis (this can be done easily by exporting and manually modifying the date in the xml to be the same and reimporting).
      5/ the result is that on this page in the main wiki, the rendered content of the document from the subwiki is displayed properly, but not the translations. That is because when the xwikimessage tool comes to loading the translations bundle from the subwiki, it finds its id in the props cache (where it was added because of the translations bundle in the main wiki) and thinks it has already loaded it, looks for the key in the cache and doesn't find it.

      Attachments

        Activity

          People

            tmortagne Thomas Mortagne
            lucaa Anca Luca
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: