On both the latest release as well as dev versions I am receiving the following notices when a user registers through the standard registration system without purchasing anything and having nothing in their cart and them clicking the validation link in the validation email.

Notices & Backtrace:

Notice: Undefined index: original in commerce_cart_user_update() (line 492 of /home/htdocs/sites/all/modules/commerce/modules/cart/commerce_cart.module).
Backtrace:
commerce_cart_user_update(Array, Object, NULL) user.module:101
user_module_invoke('update', Array, Object) logintoboggan.module:1006
_logintoboggan_process_validation(Object) logintoboggan.validation.inc:28
logintoboggan_validate_email(Object, '1365981304', 'fwQZSrawbSmRBlFrFbVFSsSPZyLeqF3HB1gxZyyv0xU')
call_user_func_array('logintoboggan_validate_email', Array) menu.inc:517
menu_execute_active_handler() index.php:28

Notice: Trying to get property of non-object in commerce_cart_user_update() (line 492 of /home/htdocs/sites/all/modules/commerce/modules/cart/commerce_cart.module).
Backtrace:
commerce_cart_user_update(Array, Object, NULL) user.module:101
user_module_invoke('update', Array, Object) logintoboggan.module:1006
_logintoboggan_process_validation(Object) logintoboggan.validation.inc:28
logintoboggan_validate_email(Object, '1365981304', 'fwQZSrawbSmRBlFrFbVFSsSPZyLeqF3HB1gxZyyv0xU')
call_user_func_array('logintoboggan_validate_email', Array) menu.inc:517
menu_execute_active_handler() index.php:28

Comments

damien tournoud’s picture

Project: Commerce Core » LoginToboggan
Component: User experience » Code

This looks like a LoginToboggan bug. This module calls the hook_user_update() hook in an incomplete way.

nicola.p’s picture

I got same problem to investigate in, if you look at commerce_cart_user_update I think part of the the problem is in

if ($account->mail != $edit['original']->mail) {

that should be

if ($account->original->mail != $edit['mail']) {

or... btw... $account is the user object on which the operation is performed as stated in API for the hook, while $edit should have mail key which in this case can't have anyway since it's a empty array crafted by _logintoboggan_process_validation.

Look also @walkah comment on http://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook...

*mumble+

bit.cyber’s picture

My site is set up such that an anonymous shopper has to create an account upon purchase, and the site uses the LoginToboggan module. The purchase proceeds OK and an email is sent to the now registered user in due course as part of the registration process. Per the report for this issue, when clicking on the validation link in the email received, the same error message is shown.

For what it's worth, I tried the fix shown in comment #2, but now get an additional error message:

Notice: Undefined property: stdClass::$original in commerce_cart_user_update() (line 492 of /home/testing/public_html/sites/all/modules/commerce/modules/cart/commerce_cart.module).
Notice: Trying to get property of non-object in commerce_cart_user_update() (line 492 of /home/testing/public_html/sites/all/modules/commerce/modules/cart/commerce_cart.module).
Notice: Undefined index: mail in commerce_cart_user_update() (line 492 of /home/testing/public_html/sites/all/modules/commerce/modules/cart/commerce_cart.module).

Otherwise the account has been validated. Their cart is of course empty given the purchase proceeded OK.

The site is using:
LoginToboggan 7.x-1.3
Commerce 7.x-1.6

nicola.p’s picture

Sorry I was wrong :( , no original for $account at this stage (checked with kpr).

Assumed that:
1. _logintoboggan_process_validation passes a object for parameter 1 $account which is ok!
2. _logintoboggan_process_validation passes an empty array for parameter 2 $edit which is used in the hook within commerce_cart_user_update, and that is not ok.

Since the hook in commerce_cart_user_update is consistent with the API, we have to fill at least the array to not raise the error, I think a viable solution would be:

$edit = array();
$edit['original'] = new stdClass();
$edit['original']->mail = $account->mail;

before the call to user_module_invoke('update', $edit, $account) in _logintoboggan_process_validation

or

$edit = array();
$edit['original'] = $account;
nicola.p’s picture

nicola.p’s picture

Status: Active » Needs review

#5

Christopher Riley’s picture

Thank you for that patch.

alexb03060’s picture

Thank you, works great.

hmartens’s picture

When is an update coming for this module or is it no longer being supported because the last time a new version came out was over 'n year ago? I want to use this module but scared it will mess up my commerce site :)

nicola.p’s picture

Just noticed that .... I'll say "LOL!" :)

ponies’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #5 works well for me.

damien tournoud’s picture

#5 looks good to me too.

bennybobw’s picture

Works for me as well

nodecode’s picture

#5 does it for me. That makes 6 thumbs up. Can we get a commit?

jcisio’s picture

Now 7.

tannerjfco’s picture

Status: Reviewed & tested by the community » Needs work

I can also confirm this patch resolves the error specifically regarding commerce - however I'm also experiencing a similar error with search_api_saved_searches. Not sure if it's the same issue, but it looks very similar so I'm venturing that it's a distinct possibility.

If it is not the same issue, or is actually an issue with search_api_saved_searches, please feel free to disregard and set back to RTBC, and I will file new issues as necessary :)

    Notice: Undefined property: stdClass::$original in search_api_saved_searches_user_update() (line 307 of search_api_saved_searches/search_api_saved_searches.module).
    Notice: Trying to get property of non-object in search_api_saved_searches_user_update() (line 307 of search_api_saved_searches/search_api_saved_searches.module).
deggertsen’s picture

Status: Needs work » Reviewed & tested by the community

@Tannerjf It looks to me that what you are experiencing is probably a separate issue. I could be wrong, but setting this back to RTBC since the patch does fix the originally defined issue.

pscl’s picture

Tannerjf,

I am getting the same Notice as you, when I click the validation link on the registration email:

    Notice: Undefined property: stdClass::$original in search_api_saved_searches_user_update() (line 245 of search_api_saved_searches/search_api_saved_searches.module).
    Notice: Trying to get property of non-object in search_api_saved_searches_user_update() (line 245 of search_api_saved_searches/search_api_saved_searches.module).

Strangely, in my case it's line 245 of search_api_saved_searches.module.
I am using the LoginToboggan module.
Did you ever manage to resolve these notices?

deggertsen’s picture

Is this still a problem in 1.4? I'm hesitant to update to 1.4 while there are still several open issues including this one that have not been committed.

As for the issue in #16 and #18. I would look at the hook_user_update in the search_api_saved_searches.module file and possibly open a new issue for that module there. It's possible that it has something to do with logintoboggan, but I do believe it would be a separate issue from this one.

blogers’s picture

For here the same problem some solution for this issue

dooug’s picture

dooug’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

It looks like this was solved in #2064919: commerce_cart_user_update assumes $edit['original'] exists

Also, based on how the core user module passes only changed values to the $edit parameter of hook_user_update(), I don't think the method the patch uses of setting $edit['original'] = $account; is correct.

Please re-open this if the notices continue to occur with the latest LoginToboggan and Commerce modules.

Please report #16 and #18 as a separate issue, unless it is in fact related.

dooug’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.