notifications_get_link() in notifications.module has this test:

if (!empty($params['sid'])) {
  $elements = array('unsubscribe', 'sid', $params['sid']);
}
elseif (!empty($params['uid'])) {
  $elements = array('unsubscribe', 'uid', $params['uid']);
}
break;

but this fails when uid = 0, causing $elements to be undefined for anonymous users, as empty() returns true for the value 0 (anonymous). This patch solves this with using isset() instead:

if (!empty($params['sid'])) {
  $elements = array('unsubscribe', 'sid', $params['sid']);
}
elseif (isset($params['uid'])) {
  $elements = array('unsubscribe', 'uid', $params['uid']);
}
break;

I guess this function is called with either 'sid' or 'uid' as a parameter, so no default else-clause should be necessary.

I have in addition tested for non-anonymous users in notifications_token_values() on the 'user' token type. This is the function causing things to fail for anonymous users. I guess there is no reason to provide links for anonymous users.

Comments

kaare’s picture

Status: Needs review » Closed (duplicate)

Ups.. I haven't search the issue queue well enough. This is apparently a duplicate to #453498.