Tried to install authcache without much luck today ... this is a warning I get when going to edit a user's profile as admin:

Notice: Undefined offset: 0 in _authcache_is_account_cacheable() (line 114 of /var/www/blahblah/modules/authcache/authcache.helpers.inc).

Comments

Status:Active» Closed (fixed)

I've made quite a few fixes / updates recently, and I don't get this warning.
Am assuming it's fixed ?

Version:7.x-1.x-dev» 7.x-1.2
Status:Closed (fixed)» Active

I'm assuming this is related to the issue I am getting.

Notice: Undefined offset: 1 in _authcache_is_account_cacheable() (line 168 of sites\all\modules\authcache\authcache.helpers.inc).

test for count($extra_roles) == 1
gurantees that $extra_roles[0] exists, but $extra_roles[1] is being accessed.

So either count($extra_roles) needs to be > 1 or $extra_roles[0] needs to be tested.. or something else.

I resolved this by changing line 168 so that

    // Admin selected a role, but did not selected "authenticated user"
    if ($extra_roles && count($extra_roles) == 1 && count($account->roles) > 1 && $extra_roles[1] == DRUPAL_AUTHENTICATED_RID  ) {
      return TRUE;
    }

becomes

    // Admin selected a role, but did not selected "authenticated user"
    if ($extra_roles && count($extra_roles) > 1 && count($account->roles) > 1 && $extra_roles[1] == DRUPAL_AUTHENTICATED_RID  ) {
      return TRUE;
    }

Which could be wrong. Can you please verify that solution is correct? Thanks.

The intention of this piece of code is to only take the "authenticated user" role into account when the user does not have any additional roles. The current implementation does not look to trustworthy and I've rewritten this part for the 2.x version. I've backported the new mechanism into the 1.x-tree (see attached patch). Would you mind testing it on the affected installation and report back whether it works?

Status:Active» Needs review

Status:Needs review» Fixed

Committed: 0d90771.

Status:Fixed» Closed (fixed)

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