I'm using user_external_login_register() as part of an external authentication module. I'm passing it good information, but it's throwing the following notice;

Notice: Undefined index: mail in user_save() (line 567 of /modules/user/user.module).
The line it's calling is $edit['mail'] = trim($edit['mail']);

I noticed that user_external_login_register() does not pass 'mail' as part of the array to user_save(). Seems it may be easiest just to throw an IF statement around that line making sure the index 'mail' exists?

I apologize if I posted this in the wrong place, just something I noticed and wanted to bring to the community's attention.

CommentFileSizeAuthor
#4 mail_fix.patch542 bytesdivzero
#3 mail_fix.diff542 bytesdivzero
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

accusoft’s picture

as an update to this, I changed line 567 in users.module to:

if (isset($edit['mail']))
{
$edit['mail'] = trim($edit['mail']);
}

and it's working perfectly now.

My preference is not to "hack the core" so I would like more opinion on this.

daften’s picture

subscribe

divzero’s picture

FileSize
542 bytes

+1

I've created accudev's fix as a patch. Attached.

divzero’s picture

FileSize
542 bytes

updated patch

divzero’s picture

Status: Active » Needs review
arosboro’s picture

I just ran into this issue as well. Thanks for the patch.

arosboro’s picture

I got a malformed error trying to use this patch on drupal 7 from the root directory

guybrush’s picture

Priority: Normal » Major

This seems like a major issue, as it effectively renders the user_external_login_register() functionality useless. It seems that it is not possible to use this function for handling remote logins without a fix.

JeebsUK’s picture

I would concur with the above comment. I understand why the patch has been implemented in the way it has because you are never guaranteed an email address, but we need to be sure the patch wouldn't affect other things adversely.

bajnokk’s picture

subscribe, on behalf of shib_auth.

SilviaT’s picture

sub