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

Saving/Creating a document that is not located on the current wiki sets the author relative to the current wiki instead of the wiki of the saved document.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3-rc-1
    • Fix Version/s: 3.3, 3.4-milestone-1
    • Component/s: Old Core
    • Labels:
      None
    • keywords:
      save create document author creator subwiki
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      Doing something like this from the main wiki while logged in as xwiki:XWiki.Admin (global admin):

      #set ($documentOnAnotherWiki = $xwiki.getDocument('someWiki:Space.Page'))
      $documentOnAnotherWiki.setContent('newContent')
      $documentOnAnotherWiki.save('modified')
      

      Will result in a modification done by someWiki:XWiki.Admin (local admin) in the 'someWiki' subwiki.

      This is because the Document.saveDocument() method gets the author from XWikiContext.getUser() which, in turn, uses the XWikiContext.getDatabase() wiki for the compactWikiEntityReferenceSerializer to resolve the user string instead of using the saved document's wiki.

      The solution is to use the user references and the previous translation problems are automatically resolved.

        Attachments

          Activity

            People

            Assignee:
            enygma Eduard Moraru
            Reporter:
            enygma Eduard Moraru
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response: