diff --git a/comment_notify.module b/comment_notify.module index 506f4a9..bf978da 100644 --- a/comment_notify.module +++ b/comment_notify.module @@ -249,13 +249,23 @@ function comment_notify_comment_update($comment) { function comment_notify_comment_insert($comment) { module_load_include('inc', 'comment_notify', 'comment_notify'); - global $user; // For new comments, we first build up a string to be used as the identifier for the alert. // This identifier is used to later unsubscribe the user or allow them to // potentially edit their comment / preferences if they are anonymous. // The string is built from their mail and comment identifier. - $mail = empty($comment->mail) ? $user->mail : $comment->mail; + if (empty($comment->mail)) { + if (empty($user->mail)) { + // We're only using this to seed a hash which might get used later, so get a random value. + $mail = user_password(); + } + else { + $mail = $user->mail; + } + } + else { + $mail = $comment->mail; + } $notify_hash = drupal_get_token($mail . $comment->cid); if (!empty($comment->notify)) {