On D7 changing a user's email address used to work.

When I enable the email_confirm module I get the following error:

Fatal error: Cannot use object of type stdClass as array in /
/modules/user/user.module on line 2710

This happens when I enter the password, the new email address and submit the form.

If I disable the module I can change the email address without errors again.

Line 2710 is the first line of this function:

function user_mail_tokens(&$replacements, $data, $options) {
if (isset($data['user'])) {
$replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user']);
$replacements['[user:cancel-url]'] = user_cancel_url($data['user']);
}
}

I have token and entity tokens installed:

token 7.x-1.x-dev
entity tokens 7.x-1.0-beta1

If you need any more details of for me to try anything, I'll do so asap.

Many thanks.

CommentFileSizeAuthor
#5 email_confirm_token.patch8.13 KBslite

Comments

Robert_M’s picture

Priority: Normal » Critical

Same error here, using 7.x-1.x-dev, released 2011-Feb-25. Priority set to "critical" as this renders this module unusable.

Robert_M’s picture

I'd like to add that in contrast to Dru-p's report, I have neither "token" nor "entity tokens" installed, so these are probably not related.

Taxoman’s picture

Subscribing.

Taxoman’s picture

Title: On line 2710, Fatal error: Cannot use object of type stdClass as array in <path to Drupal>/modules/user/user.module » Cannot use object of type stdClass as array
slite’s picture

StatusFileSize
new8.13 KB

The problem appears to be that the original code was done before token got merged into D7 core -- or at least before user_mail_tokens was updated to the token API.

I've attached a patch which converts email_confirm to use the core token API -- which includes changing the format of the tokens. I've included an (untested) migration for converting any messages that you may have customised already.

It appears to work for the limited testing that I have done so far but, as ever, YMMV.

jaydub’s picture

Thanks for the patch, I'm working it into a larger set of changes now that I finally have a tiny amount of extra bandwidth to work on the module :) If you pull the recent changes to git you'll see this change and others. I am still working on the actual confirmation of the change but for now the email sends out ok. I haven't folded in the module update to migrate settings from d6, will target that for the first official release.

jaydub’s picture

Status: Active » Closed (fixed)