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

document.get(property) displays key not value for a property of type database list which has key and value in multiwiki mode

    Details

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

      Description

      To reproduce:

      • in a subwiki, add a database list property (let's call it p) to a class, in which you add a query that selects both key and value for this database list (e.g. select doc.fullName, doc.title from XWikiDocument doc, BaseObject obj where doc.fullName = obj.name and obj.className='AppToReference.AppToReferenceClass' and doc.fullName != 'AppToReference.AppToReferenceTemplate' where "AppToReference.AppToReferenceClass" exists and has some documents with objects)'
      • create a document (let's call it D) with an object of this modified class, choose a value for the db list property
      • in view mode, this document will properly display the title of the chosen value
      • in another subwiki (or in the main wiki), in a test page, execute
        $xwiki.getDocument('full prefixed name of D').get('p') 
      • the value displayed will be the key of the database list (that is, the fullname of the referenced document) instead of the value (the title of the chosen referenced document).

      Make sure to not enable cache for the dblist property!

      This issue is caused by the fact that, in the displayView function of the dblist class, when the value to be displayed is searched (based on the stored key), the query of the dblist is executed, and it's executed for the current wiki (context.database) which does not correspond to the wiki of the class in which the dblist property. So the dblist query is relative to the database of the class, but it's executed in another wiki.

        Attachments

          Activity

            People

            • Assignee:
              gdelhumeau Guillaume Delhumeau
              Reporter:
              lucaa Anca Luca
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: