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

xwiki.getDocumentAsAuthor is broken when used in a template

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.5
    • Fix Version/s: 10.6-rc-1
    • Component/s: Old Core
    • Labels:
    • Tests:
      Unit
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      Or any other use case where the executed code is not located in the context document content.

      api.XWiki.getEffectiveScriptAuthorName() returns the author of the current document instead of using the author reference given in the context.

      As a result, calling xwiki.getDocumentAsAuthor() in a template from a thread (without any current document) badly fallback to the author of a stub document (the current document) and finally returned the document only if guest user has the right to see it.

      Note that context.getAuthorReference() returned the accurate value (superadmin in the case of a template of the file system) and that we should rely on it.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tmortagne Thomas Mortagne
                Reporter:
                gdelhumeau Guillaume Delhumeau
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: