Needs review
Project:
Invite
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Jul 2012 at 17:32 UTC
Updated:
2 Jul 2012 at 17:41 UTC
Jump to comment: Most recent file
When using modules like Fboauth, Twitter, or Linkedin, new accounts often do not have an associated email address-- the email key is left as an empty string in user_save().
This causes the invite module to throw this fatal error when a new user is created:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-1410' for key 'uid_invitee': INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, :uid FROM {invite} WHERE (email = :invite_email OR email = :account_mail) AND canceled = 0; Array ( [:uid] => 1410 [:invite_email] => [:account_mail] => ) in invite_process_invite() (line 747 of /localhost/sites/all/modules/invite/invite.module).
If two accounts have been registered with email address '', the follow chain of events will occur:
It's probably simplest to prevent this by checking the value of $account->mail with valid_email_address() in invite_user_insert(). We can modify invite_user_insert() like so:
/**
* Implements hook_user_insert().
*/
function invite_user_insert(&$edit, $account, $category) {
if (valid_email_address($account->mail)) {
$invite = invite_find_invite($account->mail);
if ($invite) {
invite_process_invite($invite, $account);
module_invoke_all('invite_accept', $invite, $account);
// Flag the inviting user, this triggers status notifications and
// saves us some queries otherwise.
if ($invite->inviter->uid) {
user_save($invite->inviter, array('data' => array('invite_accepted' => TRUE)));
}
if (isset($_SESSION)) {
unset($_SESSION[INVITE_SESSION]);
}
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | invite-check_valid_email-1668564-1.patch | 1.67 KB | grasmash |
Comments
Comment #1
grasmash commentedAttaching patch.
Comment #1.0
grasmash commentedadded links to referenced modules
Comment #1.1
grasmash commentedadding detail
Comment #1.2
grasmash commentedupdating to reflex latest 2.x integration