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

In any syntax other than xwiki/1.0, Document.getSections() returns all sections with -1 index

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 6.0-rc-1
    • Old Core
    • None
    • Unknown

    Description

      Old getSections() used to look for 1, 1.1, 1.1.1 etc and infer sections this way.
      New getSections() uses the XDOM to get the number of headers and titles of each but it is unable to get the offset in the content so it sets the value to -1.
      This is not an issue for general use because getSections() is nolonger used internally, having it's logic duplicated by XWikiDocument.getContentOfSection() and XWikiDocument.updateDocumentSection().

      In XWikiDocument

      // put -1 as index since there is no way to get the position of the header in the source
      int documentSectionIndex = -1;
      

      This is not good because public API Document.getSections() calls this, returning -1 for all sections.

      To test:

      {{velocity}}
      #foreach($sect in  $xwiki.getDocument('Sandbox.WebHome').getSections())
        $sect.getSectionIndex()
      #end
      {{/velocity}}
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            calebjamesdelisle CalebJamesDeLisle
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: