From 1a4db06bfb4aa7f787679f931ec0320daf5829b5 Mon Sep 17 00:00:00 2001
From: B-Prod <b-prod@hotmail.fr>
Date: Wed, 2 Mar 2011 22:05:10 +0000
Subject: [PATCH] Ad a check with array_key_exists() in the function masquerade_translated_menu_link_alter().

---
 masquerade.module |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/masquerade.module b/masquerade.module
index ad91b13..5afd9e5 100644
--- a/masquerade.module
+++ b/masquerade.module
@@ -149,11 +149,13 @@ function masquerade_menu_alter(&$items) {
  * Dynamically add the CSRF protection token to the Masquerade menu items.
  */
 function masquerade_translated_menu_link_alter(&$item, $map) {
-  if ($item['page_callback'] == 'masquerade_switch_user_page' && isset($map[2])) {
-    $item['localized_options']['query']['token'] = drupal_get_token('masquerade/switch/' . $map[2]);
-  }
-  elseif ($item['page_callback'] == 'masquerade_switch_back_page') {
-    $item['localized_options']['query']['token'] = drupal_get_token('masquerade/unswitch');
+  if (array_key_exists('page_callback', $item)) {
+    if ($item['page_callback'] == 'masquerade_switch_user_page' && isset($map[2])) {
+      $item['localized_options']['query']['token'] = drupal_get_token('masquerade/switch/' . $map[2]);
+    }
+    elseif ($item['page_callback'] == 'masquerade_switch_back_page') {
+      $item['localized_options']['query']['token'] = drupal_get_token('masquerade/unswitch');
+    }
   }
 }
 
-- 
1.7.4.msysgit.0

