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

XWikiDocument.rename changes object GUIDs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 2.0 M4
    • Old Core
    • None
    • patch
    • Unknown
    • Awaiting Committer feedback

    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

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

              Dates

                Created:
                Updated: