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

The space table is not updated when using XWikiDocument#copyDocument() api

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      I am using the XWikiDocument#copyDocument(DocumentReference newDocumentReference, XWikiContext context) API in a groovy script in order to copy a document to a new location.

      The copy is working but I have this warning on the logs :

      Space [Space ***] does not exist. Usually means the spaces table is not in sync with the documents table.

      I checked the xwikispace table and I find that the new space is not created.

      Follow these steps to reproduce :

      • XWiki 13.4.3
      • Create a test page : Sandbox.MyTestPage.WebHome
      • Create a script page (Sandbox.CopyPageScript) that will be used to copy the page created above to this location Sandbox.MyNewTestPage.WebHome, copy the following script on its content, save and view the page
        {{groovy}}
        def sourceDoc = xwiki.getDocument('Sandbox.MyTestPage.WebHome').getDocument()
        def targetDocumentReference = services.model.createDocumentReference('', ['Sandbox', 'MyNewTestPage'], 'WebHome')
        def targetDoc = sourceDoc.copyDocument(targetDocumentReference, xcontext.getContext())
        xcontext.getXWiki().saveDocument(targetDoc, "", xcontext.context)
        {{/groovy}}
        

      Expected results : the page is copied to 'Sandbox.MyNewTestPage.WebHome' without any warning and the new page space is added to the xwikispace table
      Current result : the page is copied but the space of the new page is not added to the xwikispace table.

      the sql query select * from xwikispace where XWS_REFERENCE like 'Sandbox.MyNewTestPage'; return 0 results.

      Attachments

        Activity

          People

            tmortagne Thomas Mortagne
            mouhb Mohamed Boussaa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: