When trying to save an XWikiDocument instance that was created outside the API (thus, "synthetic"), like for example at XAR import (when each document is created from its XML representation), listeners to DocumentUpdat(ing/ed)Event will never be notified, even when a version of the imported document already exists in the database (overriding import).
This is because in the saveDocument method, we always create an originalDocument for XWikiDocuments that have none (synthetic documents), but we never set the isNew flag on this originalDocument. This means that, below in the code when originalDocument.isNew() is checked, it will always return true and always notify listeners of DocumentCreat(ing/ed)Event.
The right way would be that, when we create originalDocument for synthetic XWikiDocuments, we should also do:
However, it is quite costly to do an additional DB query, at each save.