I was investigating a bug last night and found that the handler for the SecureHook I had set on a blizzard function does not get called if I also set an upvalue for that function for my own calls to it.
So basically, I had:
local _G, CallCompanion = _G, CallCompanion
The game calls CallCompanion if you open the Mount Journal, select a mount and click the button to summon it. My handler function would only get called if I removed the upvalue for CallCompanion.
Can anyone shed some light on why I'm seeing this behavior?
A hook replaces the function. It does not matter if its a secure hook or a manual insecure hook.
If you keep a reference to the original function in a upvalue, it will not see the hook. Thats just how hooks work.
SecureHooks are no different then a manual hook, its just executed in secure code to avoid taint.
There is no way that AceHook can mess with, or be messed by, the lexically-scoped CallCompanion.
So either he is calling CallCompanion from his code below that statement and the local actually shadows the global, hooked CallCompanion, either there is something else, including CallCompanion being unhookable because Blizzard also use an upvalue in their code.
He's saying using the Mount Journal and having the game call _G.CallCompanion doesn't trigger CallCompanionHook.
Yeah, if it had just been the call in my code that wasn't triggering the callback I wouldn't have posted. It was the callback not getting triggered by the mount journal that I couldn't understand.
However, I can't seem to reproduce the problem anymore, which is very frustrating. :(
Sticking a print statement in the callback makes it simple enough to test. I've no idea how I could have screwed it up but unless I can get it reproing again we have to assume the problem was me. Sorry for wasting people's time.