#Can we detect in a hook when the current transaction has been rolled back?

4 messages · Page 1 of 1 (latest)

dense lion
#

Let's say, I am making a plugin which add a hook at the end of the hook array. However, this "last hook call" should never execute unless the operation was fully completed.

I guessed it was safe to assume that if a call to this last hook is made, then that means the operation was carried over since it never threw an error and the execution continued. However, if a hook rolls back a transaction but doesn't throw, the hooks are called as if nothing happened.

Is there a way to check the "status" of a transaction?

sour sunBOT
rain citrus
#

any db changes that you do in your plugin will be auto rolled back, don't think it'll be a problem. For your own use case, other than db transactions, maybe you can add a hidden field/context flag or do extra checks with another hook in afterOperation

dense lion
#

Yeah, I figured a context flag would be needed 🤔
Alright! Thanks