On Wed, Apr 13, 2016 at 11:54 PM, Sergiu Dumitriu wrote:
> On 04/13/2016 03:10 AM, Thomas Mortagne wrote:
>> On Tue, Apr 12, 2016 at 10:11 PM, Vincent Massol wrote:
>>> Hi Peter,
>>>
On 05 Apr 2016, at 19:28, Peter Huisman wrote:
From the XWiki source code, I see there is a difference in passing a
document to the evenmanager:
The DocumentDeletingEvent is passing a “new
XWikiDocument(doc.getDocumentReference())"
The DocumentUpdatedEvent (as an example) is passing the doc (the actual
XWikiDocument)
The difference is, that the Document passed in the DeleteEvent is a new
XWikiDocument and not the XWikiDocument that is about to be deleted.
Is there a reason why this difference exists?
>>>
>>> he code in the XWiki class doing the notify has been there for a long time
>>> AFAICS:
>>>
>>> om.notify(new DocumentDeletingEvent(doc.getDocumentReference()),
>>> new XWikiDocument(doc.getDocumentReference()), context);
>>>
>>> However, I think it’s not correct. I think it should pass the document and
>>> not a clone, because an Event Listener should be able to modify the
>>> instance that’s going to be saved.
>>
>> It's a delete not a save so modifying it would be useless. I guess the
>> intend here was to have the same kind of data than what you get with
>> DocumentDeletedEvent.
>>
>> What is wrong and should be fixed is that the document sent with the
>> event should have the real one as original document (exactly like it's
>> done for DocumentDeletedEvent).
>
> Thomas is right, the data sent in the event is supposed to be what the
> database will contain after the event is done, and that's what will
> (apparently, but not actually) be in the database after the delete: a
> new blank document, and doc.originalDoc should be what was before the
> change in the database. At least this was the original intention, all
> events should behave like this, so that a diff can be computed between
> doc and originalDoc regardless of what action happened to the document.
>
> However, the Javadoc for DocumentDeletingEvent is misleading:
> https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java#L31
Javadoc is now fixed.
>
>>>
>>> So I’d open a bug for this. Let’s see if the others agree.
>>>
>>> Thanks
>>> -Vincent
>>>
>
>
> --
> Sergiu Dumitriu
> http://purl.org/net/sergiu/
> ___
> users mailing list
> us...@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne
___
devs mailing list
devs@xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs