I just upgraded a site from 7.x-2.0-beta1 to 7.x-2.0-rc1 and now I'm getting:

Notice: Undefined index: view in administerusersbyrole_metadata_user_access() (line 235 of mysite\site\sites\all\modules\administerusersbyrole\administerusersbyrole.module).

Watchdog shows the location that is triggering this is an ajax call from a view:

Location: http://mysite.com/views/ajax

Comments

dave kopecek’s picture

Is this a mismatch in call to entity_metadata_user_access ?

from /entity/modules/callback.inc line 706:

function entity_metadata_user_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) 

call from administerusersbyrole line 228:

function administerusersbyrole_metadata_user_access($op, $account = NULL, $check_as = NULL) {
  // Call the base function.
  if (entity_metadata_user_access($op, $account, $check_as)) {
    return TRUE;
  }
adamps’s picture

Hi, thanks for the report.

I think it's a harmless warning. Sorry I didn't spot it because I have my warning levels too low in my own testing. Basically the code accesses an array key that doesn't exist (generates a notice), and then immediately after does the safety check if the value is set. I will upload a fix.

Regarding #1, in summary no I'm pretty sure it's fine. It's pretty confusing I admit, but the two modules use the variable names in different ways. The entity module passes $entity, but in this case the entity is in fact a user account object users are entities of course), which in this module we call $account throughout, so I stuck with that.

adamps’s picture

Status: Active » Fixed

Well I don't know if I can figure out a way to see the warning on my site. But I have some code that I think will fix it - tested the basic function still works at least. Please let me know if the next dev release that is built fixes for you.

  • AdamPS committed 3bbff54 on 7.x-2.x
    Issue #2542336 by AdamPS: Undefined index: view '
    
dave kopecek’s picture

Thanks for your quick response. 3bbff54 on 7.x-2.x seems to do the trick.

For the record, the code before the fix can cause more than just harmless warnings. I have a "user" based view where administerusersbyrole_metadata_user_access() is getting called twice per view row. One call with $op='view', one with $op='update'.

With the original code administerusersbyrole_metadata_user_access() returns false when it should not for some users.

Running the view as an administrator returns the correct records, running the view as a non-admin would return an incorrect subset of the view's result rows. 3bbff54 on 7.x-2.x appears to fix the issue.

My view may be an edge case but it's worth mentioning to spare others pain.

adamps’s picture

@Dave Kopecek Thanks for posting back with the update.

Status: Fixed » Closed (fixed)

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