I've got a custom view designed to grab some basic profile data from my users to display in comments (Gender, Custom Title etc). This works fine, until I query the user's role. If the user lacks a custom role (IE: Moderator, Administrator) the following error is spit out for as many times as a user posts with the role of simply "registered user". I would presume this would also apply to anonymous users, save I have no intent on letting anonymous users participate interactively on my site.
Notice: Undefined index: role in views_handler_field_user_roles->add_self_tokens() (line 44 of drupal/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc).
Notice: Undefined index: rid in views_handler_field_user_roles->add_self_tokens() (line 45 of drupal/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc).
In the event that Views is unable to procure a role, I have results rewritten to say "Registered User". Thus the results Views outputs is 100% the desired result. It's the existence of a looped error message that I currently find undesirable.
I appreciate your patience in taking the time to look at this.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 1338686.patch | 746 bytes | dawehner |
| #3 | views-empty-user-role-1338686-3.patch | 594 bytes | paul.moloney |
| Error.txt | 13.17 KB | Wooster |
Comments
Comment #1
dawehnerThis code runs the self tokens, so actually $item can't be empty here. In general it shouldn't be too hard to introduce the check on the right place, but i'm wondering why this doesn't work already.
Comment #2
Wooster commentedI'm no expert on Drupal, so what follows is me thinking out loud, Perhaps Drupal treats Registered and Anonymous users differently from roles that can be added. So to the end user/admin Admin, User, and Guest may appear conceptually the same, Admin is functionally different from Registered and Guest? Views makes the reasonable assumption that a role is a role, when it isn't?
Comment #3
paul.moloney commentedHere's a basic patch that has fixed the problem for me. I've simply checked if $item['role'] is empty, if not then proceed with assigning the tokens.
Comment #4
dawehnerI'm wondering what happens with these tokens, are they still replaced?
Comment #5
tim.plunkettTriggering the testbot.
Comment #7
dawehnerYou have to run your test so it can be applied via patch -p1, see http://drupal.org/patch/submit
Comment #8
dawehnerHere is a small rerole
Comment #9
dawehnerThat's a simple patch, let's get it in, so committed to 7.x-3.x and 6.x-3.x