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

XWikiDocument.rename changes object GUIDs

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0 M4
    • Fix Version/s: None
    • Component/s: Old Core
    • Labels:
      None
    • keywords:
      patch
    • Difficulty:
      Unknown
    • Pull Request Status:
      Awaiting Committer feedback
    • Similar issues:

      Description

      to repeat:
      create a document and call it anything except newDoc.
      In it put this:

      These two GUIDs should be the same
      {{groovy}}
      def oldName = doc.getName()
      def obj = doc.getObject("TagClass");
      println(obj.getGuid().toString());
      doc.rename("newName");
      def newObj = doc.getObject("TagClass");
      println(newObj.getGuid().toString());
      doc.rename(oldName);
      {{/groovy}}
      

      Solving this is more complex than it first appears.
      XWikiDocument.rename calls XWiki.copyDocument and XWiki.copyDocument calls XWikiDocument.copyDocument and then calls XWiki.saveDocument.
      By the time XWikiDocument.rename gets the copy back, it is already saved. If we are to fix the objects after the copy event, rename will then need to save the document (and all translated versions) twice, otherwise we could add another boolean variable to XWiki.copyDocument which decides should it change GUIDs and thus the problem is solved before saveDocument is called.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              calebjamesdelisle CalebJamesDeLisle
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Date of First Response: