After upgrading from 7.x-2.6 to 7.x-2.9, I received the following error while visiting a view that integrates user locations:

Notice: Undefined property: stdClass::$uid in commerce_kickstart_user_username_alter() (line 58 of /home/solar/public_html/profiles/commerce_kickstart/modules/commerce_kickstart/commerce_kickstart_user/commerce_kickstart_user.module).

I tweaked the module by adding an isset() on line 58, and it seems to have fixed the issue, but since I have very limited dev knowledge, I wanted a second opinion. The code is listed below from lines 53-65 from the commerce_kickstart_user.module:

 * Implements hook_username_alter().
function commerce_kickstart_user_username_alter(&$name, $account) {
  if (module_exists('commerce_addressbook')) {
    if (isset ($account->uid)) {$billing_profile_id = commerce_addressbook_get_default_profile_id($account->uid, 'billing');
      if ($billing_profile_id) {
	$billing_profile = commerce_customer_profile_load($billing_profile_id);
	$name = $billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'];
#1 username_alter_error-2053175-1.patch908 bytesvasike


vasike’s picture

Version: 7.x-2.9 » 7.x-2.x-dev
Status: Active » Needs review
908 bytes

here is a patch that should solve this.

vasike’s picture

here is a gerrit commit :
add an extra check to avoid Anonymous user.

jsacksick’s picture

Status: Needs review » Needs work

!empty is enough, you don't have to do !isset && !empty

vasike’s picture

Status: Needs work » Needs review
jsacksick’s picture

Status: Needs review » Fixed


Status: Fixed » Closed (fixed)

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

beatdrop’s picture

Thanks, This totally solved the issue for me. This is the type of problem that would have basically kept me up late for days trying to fix it. This is why I stuck with Drupal. The community rocks!!

GEO’s picture

At the Order list still get an error when custumer is guest (and order status is "in cart").
Need to additional check at string 59, I've changed next:

    if ($billing_profile_id) {


    if (is_object ($billing_profile_id)) {

Works for me.

GEO’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work

Just change status according to #8

jsacksick’s picture

Status: Needs work » Closed (fixed)

@GEO: Your change is wrong, the function returns an id, we can't expect an object here...