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

doc.display( fieldName ) and doc.display( fieldName, mode ) can have different results in the same context

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.9.1, 2.0 M2
    • 1.9, 2.0 M1
    • {Unused} Core
    • None
    • any
    • display
    • Unit
    • Unknown

    Description

      doc.display( fieldName ) ends up in:

      public String display(String fieldname, String type, BaseObject obj, XWikiContext context)
      {
          return display(fieldname, type, "", obj, context.getWiki().getCurrentContentSyntaxId(getSyntaxId(), context), context);
      }
      

      while doc.display( fieldName, mode ) ends up in:

      public String display(String fieldname, String mode, String prefix, XWikiContext context)
      {
          try {
              BaseObject object = getxWikiObject();
              if (object == null) {
                  object = getFirstObject(fieldname, context);
              }
              if (object == null) {
                  return "";
              } else {
                  return display(fieldname, mode, prefix, object, context.getDoc() != null ? context.getDoc().getSyntaxId() : getSyntaxId(), context);
              }
          } catch (Exception e) {
              return "";
          }
      }
      

      Both finally call the same method but the way the syntax parameter is determined differs. This can lead to different results even when the display methods are executed in the same context. Here are the steps:

      • create a blog article
      • change its syntax to xwiki/2.0 and set its content to
        {{velocity}}{{html}}#includeForm("X.Y"){{/html}}{{/velocity}}
        
      • edit the article object and put some xwiki/2.0 content
      • create the X.Y page in xwiki/1.0 syntax and set its content to
        $doc.display("content")
        
        ----------
        
        $doc.display("content", "view")
        
      • view the blog article

      Attachments

        Activity

          People

            tmortagne Thomas Mortagne
            mflorea Marius Dumitru Florea
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: