Index: masquerade.module =================================================================== --- masquerade.module (revision 2375) +++ masquerade.module (working copy) @@ -34,6 +34,10 @@ function masquerade_init() { global $user; + if (empty($user->uid)) { + return; + } + // load from table uid + session id $uid = db_result(db_query("SELECT uid_from FROM {masquerade} WHERE sid = '%s' AND uid_as = %d", session_id(), $user->uid)); // using if so that we get unset rather than false if not masqing @@ -540,7 +544,7 @@ function masquerade_switch_user($uid) { global $user; - if (!is_numeric($uid)) { + if (!is_numeric($uid) || empty($uid)) { drupal_set_message(t('A user id was not correctly passed to the switching function.')); watchdog('masquerade', 'The user id provided to switch users was not numeric.', NULL, WATCHDOG_ERROR); return drupal_goto(referer_uri());