I installed latest DEV version and getting the following error on all /user pages:
Warning: Missing argument 2 for commerce_addressbook_profile_page_access() in commerce_addressbook_profile_page_access() (line 151
Notice: Undefined variable: profile_type in commerce_addressbook_profile_page_access() (line 155
I think error is caused by missing access argument $type in commerce_addressbook_menu user/%user/addressbook.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Christopher Riley’s picture

I am running into the same issue on a fresh install.

vasike’s picture

Priority: Normal » Critical

i can confirm this issue and i think this a critical one.
should be checked/tested on a clean install.

there, in the (addressbook menu items definition and their callback functions) 2 issues:
1. the missing argument for the

$items['user/%user/addressbook'] 

solution proposal to use the "billing" as default argument for the customer profile type.
a. could be in the menu item definition
or
b. in the functions definition for profile type argument.
Or
c. create a new helper function with somthing similar as user_page() function

  if ($user->uid) {
    menu_set_active_item('user/' . $user->uid . '/addressbook/billing');
    return menu_execute_active_handler(NULL, FALSE);
  }

2. Access callback functions for the addressbooks have

  // The addressbook is not enabled for this profile type.
  if (!variable_get('commerce_customer_profile_' . $profile_type . '_addressbook', FALSE)) {
    return FALSE;
  }

i can't find such variable. maybe this is something old remained there.
without this variable we'll have Access denied for all addressbook pages.

So is this variable check still a valid one?

bojanz’s picture

The variable check is fine.

Note the code in hook_menu() that's supposed to add the second argument:

  if ($first && $enabled) {
    // The parent menu item needs to point to the first profile type.
    $items['user/%user/addressbook']['page arguments'][] = $type;
    $items['user/%user/addressbook']['access arguments'][] = $type;
    $first = FALSE;
  }

This code doesn't execute, hence the fail. Find out why.

vasike’s picture

Status: Active » Needs review
FileSize
6.5 KB

the source of this issue is no profile addressbook enabled.
here is a patch that should build the right menu items only for profile types with addressbook enabled.

but it doesn't look so good for me. as it requires menu to be rebuilt for any enable/disable the addressbook.

i'm thinking about having different approach (instead of hook_menu) for the user addressbook pages.
To have a display for disabled and profiles views for the enabled ones.
The only issue in this case is which should be the default/first (for $items['user/%user/addressbook']).

vasike’s picture

the current $items['user/%user/addressbook'] menu items doesn't provide a solution if we have no addressbook enabled.
it will also not work if we disable all the addressbooks (initially enabled).
this menu item it's built depending on a presumed profile type with addressbook enabled.

i built a patch that redefines this menu item, which calls new page and access callbacks functions, profile type independent.
the access callback return the first profile type with addressbook enabled if any or FALSE.
using this type will return with the page callback the addressbook profile page.

this patch moves the logic from menu building to menu item access callback as we have for every profile type addressbook.

TimelessDomain’s picture

patch #5 fixed the error for me. thanks!

krisrobinson’s picture

I can confirm patch from #5 fixed this error on my fresh install.

vasike’s picture

it seems there's still an issue with the 'user/%user/addressbook' menu item.
#1804790: Address Book issue, admin can't view users' address book!

here is the updated patch.

jsacksick’s picture

Status: Needs review » Fixed

Commited to dev, thanks.

Status: Fixed » Closed (fixed)

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

wc_anwar’s picture

Status: Closed (fixed) » Active

the dev version still provides the unpatched version.

jsacksick’s picture

bojanz’s picture

Status: Active » Closed (fixed)