Hi,
I have an extension that listens for DocumentUpdatedEvent
, intended to pick up when a user modifies the normal page content. I have code that detects whether the main content has changed using the Delta list.
When that event happens, the extension modifies an XObject that is attached to that same document/page and calls Document#save()
.
Because there is a change to the XObject, that appears to cause a DocumentUpdatedEvent (which makes sense) but because the first event raised hasn’t completed yet and the page still has an entry in the Delta list, my code loops.
I have tried running the bit of code that modifies the XObject in another thread but setting values on the XObject requires the xcontextprovider and that doesn’t work, I assume because it’s not in an XWiki managed thread.
Does anyone have any ideas on how I can either stop the loop by improving the initial checks I perform when a DocumentedUpdatedEvent
happens or, how I can run my XObject task in another thread properly? Or any other ideas?
Thanks in advance,
Alex