Skip to content
Permalink
Browse files

fix(widgets): validate get_list,default_widgets hook output

Validates the data returned by get_list,default_widgets hook before trying
to register event handlers.
Fixes invalid offset warnings.
  • Loading branch information...
hypeJunction committed May 9, 2015
1 parent 6af9814 commit b1c16311ea3a129e5b885d34765d6b892b42130e
Showing with 12 additions and 4 deletions.
  1. +12 −4 engine/lib/widgets.php
@@ -197,10 +197,18 @@ function _elgg_default_widgets_init() {
// only register the callback once per event
$events = array();
foreach ($default_widgets as $info) {
$events[$info['event'] . ',' . $info['entity_type']] = $info;
}
foreach ($events as $info) {
elgg_register_event_handler($info['event'], $info['entity_type'], '_elgg_create_default_widgets');
if (!is_array($info)) {
continue;
}
$event = elgg_extract('event', $info);
$entity_type = elgg_extract('entity_type', $info);
if (!$event || !$entity_type) {
continue;
}
if (!isset($events[$event][$entity_type])) {
elgg_register_event_handler($event, $entity_type, '_elgg_create_default_widgets');
$events[$event][$entity_type] = true;
}
}
}
}

0 comments on commit b1c1631

Please sign in to comment.
You can’t perform that action at this time.