]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4948, #4686 checking that event/hook exists before trying to unregister
authorcash <cash.costello@gmail.com>
Sat, 8 Dec 2012 15:37:51 +0000 (10:37 -0500)
committercash <cash.costello@gmail.com>
Sat, 8 Dec 2012 15:37:51 +0000 (10:37 -0500)
engine/lib/elgglib.php

index dd3cba25da7f7d09018dcc70714b3ec94c880c28..b9cc1a087f31da3a3684a5cbb3253c98a7877c3f 100644 (file)
@@ -710,9 +710,12 @@ function elgg_register_event_handler($event, $object_type, $callback, $priority
  */
 function elgg_unregister_event_handler($event, $object_type, $callback) {
        global $CONFIG;
-       foreach ($CONFIG->events[$event][$object_type] as $key => $event_callback) {
-               if ($event_callback == $callback) {
-                       unset($CONFIG->events[$event][$object_type][$key]);
+
+       if (isset($CONFIG->events[$event]) && isset($CONFIG->events[$event][$object_type])) {
+               foreach ($CONFIG->events[$event][$object_type] as $key => $event_callback) {
+                       if ($event_callback == $callback) {
+                               unset($CONFIG->events[$event][$object_type][$key]);
+                       }
                }
        }
 }
@@ -889,9 +892,12 @@ function elgg_register_plugin_hook_handler($hook, $type, $callback, $priority =
  */
 function elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback) {
        global $CONFIG;
-       foreach ($CONFIG->hooks[$hook][$entity_type] as $key => $hook_callback) {
-               if ($hook_callback == $callback) {
-                       unset($CONFIG->hooks[$hook][$entity_type][$key]);
+
+       if (isset($CONFIG->hooks[$hook]) && isset($CONFIG->hooks[$hook][$entity_type])) {
+               foreach ($CONFIG->hooks[$hook][$entity_type] as $key => $hook_callback) {
+                       if ($hook_callback == $callback) {
+                               unset($CONFIG->hooks[$hook][$entity_type][$key]);
+                       }
                }
        }
 }