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

XWiki#getDocumentReference resolves relative page references in the main wiki instead of the current wiki

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 10.6
    • Old Core
    • None
    • Unknown

    Description

      XWiki#getDocumentReference(EntityReference) (and so XWiki#getDocument(EntityReference, XWikiContext) and the script API $xwiki.getDocument(EntityReference)) does not resolve a relative page reference (an EntityReference of type PAGE without its wiki or parent pages) the way it resolves a relative document reference: the missing parts come from the default values (main wiki, Main page) instead of the current context.

      The cause is AbstractCurrentGetReferenceResolver#resolveInternal, which completes PAGE related references with the default PageReferenceResolver, while DOCUMENT related references go through the current one. The class even injects a current PageReferenceResolver which is never used.

      It does not affect PageReference instances, which always contain the wiki, only relative references built as EntityReference.

      STEPS TO REPRODUCE:

      • Have the context on the wiki subwiki
      • Call XWiki#getDocumentReference with the relative document reference new EntityReference("Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE))
      • Call it with the equivalent relative page reference new EntityReference("Page", EntityType.PAGE, new EntityReference("Space", EntityType.PAGE))

      EXPECTED RESULTS:
      Both references are resolved in the current wiki: subwiki:Space.Page for the document reference, and subwiki:Space.Page.WebHome (or subwiki:Space.Page if only the terminal document exists) for the page reference.

      ACTUAL RESULTS:
      The document reference is resolved to subwiki:Space.Page, but the page reference is resolved to xwiki:Space.Page.WebHome, in the main wiki.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tmortagne Thomas Mortagne
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: