You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The after_channel_entry_save event hook is called twice for every add-on using it #248
Description of the problem
It appears the after_channel_entry_save hook is getting called twice for every add-on using it, even if there is only 1 row per add-on in the exp_extensions table for the hook.
How To Reproduce
Install an add-on using that hook, step debug, or log to file inside the add-on's method using the hook and you'll see it gets called twice every time an entry is saved. I tested this with 1 add-on installed, then a 2nd add-on, and they both have their after_channel_entry_save hook called twice. I also tested this in two different EE environments. One using 5.2.3, and another 5.2.4.
Nope, one of the is Reading Time Pro, and there are no instances of ->save in its codebase. Publisher does call save on some models, but I commented those calls out while testing and it didn't make a difference... the hook was still called twice.
Activity
derekjones commentedon Jul 3, 2019
Curious. Are either of those add-ons calling a new
save()on the model?litzinger commentedon Jul 3, 2019
Nope, one of the is Reading Time Pro, and there are no instances of
->savein its codebase. Publisher does call save on some models, but I commented those calls out while testing and it didn't make a difference... the hook was still called twice.litzinger commentedon Jul 3, 2019
Ok, I uninstalled Publisher and just tested RTP, and it wasn't called twice. So maybe it was a Publisher issue, but I can't pinpoint it yet.
litzinger commentedon Jul 3, 2019
I take that back. When creating a new entry, the hook in RTP is called twice. When editing it is called once. Publisher is not installed.
derekjones commentedon Jul 8, 2019
Is this occurring with the latest public release of Reading Time Pro so I can replicate or just in dev?
litzinger commentedon Jul 8, 2019
Yes it is.
derekjones commentedon Jul 8, 2019
Can you double check to see if you have two rows for that hook and method in your
exp_extensionstable? At the top of your method, I added:Watching the file live while saving, it only adds a single line for each save.
derekjones commentedon Jul 8, 2019
Scratch that, reading comprehension. I'm also seeing the redundancy you are on new entries.
dougblackjr commentedon Jan 16, 2020
Added PR #352 to address this one. I'm not sure it's the most elegant solution, so I invite feedback.
Merging bug/248-hook-firing-twice, resolves ExpressionEngine#248