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

In a DocumentCreated EventListener, if the saved document is modified and saved again, a DocumentCreatedEvent is sent instead of a DocumentUpdatedEvent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 3.1.1
    • Old Core
    • None
    • Unknown

    Description

      To reproduce, you should use a code like this in a DocumentCreatedEvent listener:

      XWikiDocument currentDocument = (XWikiDocument) source;
      XWikiContext context = (XWikiContext) data;
      // create some new object in the document here, change stuff in it
      ...
      context.getWiki().saveDocument(currentDocument, ...)
      

      On this last save, the same DocumentCreatedEvent is being fired, even if we're saving a document which already exists.

      The issue might be caused by the fact that this code is casting event parameters to XWikiDocument (which is oldcore), but there are enough situations when listeners need to use the fact that the event params are XWikiDocuments (and anyway, some cast need to be done, so I would say that we cannot call this issue a "won't fix" for this reason).

      Attachments

        Activity

          People

            Unassigned Unassigned
            lucaa Anca Luca
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: