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

The location preview uses a wrong wiki and errors are logged when the parent field of the location picker contains the wiki

    XMLWordPrintable

Details

    • Unknown

    Description

      Steps to reproduce

      1. Open the Copy (or Rename / Create) form of a page
      2. In the location picker, type in the parent field a space reference that includes the wiki, e.g. xwiki:Space.Target

      Expected

      The location preview (breadcrumb) shows the Space > Target location in the xwiki wiki, and nothing is logged.

      Actual

      The location preview is computed for a reference whose wiki is xwiki:xwiki, and errors are logged on the server, e.g.:

      ERROR ghtCheckerAuthorizationManager - Failed to load rights for user [xwiki:XWiki.CopyRightsUser] on [Space xwiki:xwiki:NestedCopyPageIT].
      org.xwiki.security.authorization.AuthorizationException: Could not retrieve the document to check security access when checking access to [xwiki:xwiki:XWiki.XWikiPreferences]
      Caused by: com.xpn.xwiki.XWikiException: Error number 2 in 0: No wiki with id [xwiki:xwiki] could be found
      

      and

      ERROR c.x.x.d.XWikiDocument - Error when loading document [xwiki:xwiki:CopyWithChildrenTarget.WebHome] for locale [en]
      Caused by: com.xpn.xwiki.XWikiException: Error number 2 in 0: No wiki with id [xwiki:xwiki] could be found
      

      The copy / rename itself uses the right location.

      Cause

      updateLocation in uicomponents/widgets/locationPicker.js resolves the parent field as a space reference, then always calls spaceReference.appendParent(new XWiki.WikiReference(wiki)). When the parent field already contains the wiki, the resolved reference already has a wiki parent, and appendParent adds a second one above it: the reference sent to the hierarchy_reference template is serialized as xwiki:xwiki:Space.Target.WebHome, whose wiki is parsed as xwiki:xwiki. The same file already resolves the parent field with the wiki as a default value instead (XWiki.Model.resolve(parentField.val(), XWiki.EntityType.SPACE, [wiki])), which is what the copy / rename templates do too.

      Seen on CI with the functional tests CopyPageIT and RenamePageIT, which fill the parent field with a serialized space reference including the wiki.

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: