The account object in views_plugin_argument_validate_user.inc is not correctly constructed.

There is a typo which prevents the proper initialisation of the roles array.

Also, the roles probably do not need to be explicitly loaded in all cases since the roles are already part of the user object.

Comments

merlinofchaos’s picture

Assigned: Unassigned » merlinofchaos

Assigning so I can find this again.

avpaderno’s picture

StatusFileSize
new1.09 KB

This is the patch for Views 6.x-2.x.

avpaderno’s picture

Status: Active » Needs review
StatusFileSize
new1.03 KB
new1.02 KB

These are the patch for the other development snapshots.
The patches simply fix the typo.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches. Thanks!

Status: Fixed » Closed (fixed)

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

CalebD’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Assigned: merlinofchaos » CalebD
Status: Closed (fixed) » Needs review
StatusFileSize
new1.29 KB
new1.3 KB

After updating to the latest version of views I was having an issue where some views acted as if they were empty. After some debugging, I traced it back to the code change implemented by this bug fix. I don't think the fix here is entirely correct. The bug fix actually causes views to wipe out the user roles of the global user object.

$account->roles should only be initialized if it doesn't already exist. Sometimes $account is a reference to the global user object, which will already have its roles populated.

The roles array structure is incorrect. The current code just ads the role ID to the array, but the proper structure is to use the role ID as the array key and the role name as the value.

Attached are two patches against 7.x-3.x-dev and 6.x-3.x-dev.

Note the original poster actually points this out:

Also, the roles probably do not need to be explicitly loaded in all cases since the roles are already part of the user object.

dawehner’s picture

Assigned: CalebD » Unassigned
Status: Needs review » Closed (fixed)

Stuff like this is always aready reported :) See #832954-32: global $user->roles get changed by argument_user_validate

Thanks for writing a patch.