When debugging some event I added an elgg_log statement like below.
When checking the log, it turns out that it runs 4 times, that should not be the case, since the second time it runs the group_name and group_name_new are the same. This is not a functional issue for the code, but definitely a performance one.
Anyone know why this behaviour is ?
elgg_register_event_handler('update', 'group', 'my_new_event');
function my_new_event($event, $type, $params)
{
$group_name_new = get_input("name");
$group_name = $params->name;elgg_log('Group var is '. $group_name .' and new group is '. $group_name_new . ' being made ', 'DEBUG');
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- Gerard@gkanters
Gerard - 0 likes
You must log in to post replies.The event will trigger each time $group->save() is called. Are you sure it's not being called multiple times?
Ah, It seems that $group->save() is called twice from a plugin. That at least explains two of the runs, but not 4 but will see if we can clean this up.