HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Explaining how custom handlers work
So i was reading this documentation here https://docs.vanillaforums.com/developer/addons/events-and-handlers/ and I understand how a handler works.. I can have my plugin code alter/add/remove/read date based on the fireEvent trigger..
I was looking at the following code form another plugin and saw this function that is attaching to what? It does not end with Handler. I assume this is acting on the /applications/vanilla/controllers/class.categoriescontroller.php but where inside that file would this codes insertion point be?
public function categoriesController_render_before($sender) { // Do some stuff }
0
Comments
Magic events were an elaborate system of hook possibilities that involved the method prefix ‘x’ and PHP’s
__call()
method. Currently, there is only one undeprecated magic event in Vanilla:render_before
. It invokes just before the page is rendered. Example use:base_render_before($sender)
. It is best to avoid when another event is usable.So does this mean that in the entire "/applications/vanilla/controllers/class.categoriescontroller.php" if there is a call to "$this->render()" this function will fire?
Correct. Simply add
echo '<!-- my test -->';
orecho '<!-- ' . $sender->RequestMethod . ' -->';
there and look at the resulting html to validate your assumption. And even worse than usingsomeController_render_before
isbase_render_before
, because that is called at the beginning of every controller render call. Just take a look at the source code to understand why you should avoid abusing that magic method... https://github.com/vanilla/vanilla/blob/release/3.3/applications/vanilla/settings/class.hooks.php#L656-L667 😉