In my training today we tried to setup a tax calculation rule to only include tax for anonymous users. The actual use case is irrelevant, but the bug that we found is that site:current-user does not work for "User has role(s)." I edited the condition's code to dump the $account->roles variable and it of course had no data. Is this a problem with the account as loaded by Drupal? My explicit check was for the "anonymous user" role. I worked around it by negating a check on the "authenticated user" role, but it seems if anonymous is included in the options list it ought to accommodate a user account with no roles.

CommentFileSizeAuthor
#4 entity_user.patch485 bytesfago

Comments

carsonw’s picture

I have the exact same issue as rszrama.

simon_s’s picture

I can confirm this problem with site:current-user role anonymous user also for Version 2.0 7.x.
A condition on role anonymous with site:current-user never gets true.

fago’s picture

That's strange. drupal_anonymous_user() properly contains the role, so maybe the entity property gives back a wrong user object in that case.

fago’s picture

Status: Active » Needs review
StatusFileSize
new485 bytes

That entity patch should do it - please test.

simon_s’s picture

Thanks a lot fago, with this entity patch applied it works now for anonymous users!

(I use it for silent node flagging on viewing nodes (with rules + entity api + flags + session api))

fago’s picture

Project: Rules » Entity cache
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Rules Engine » Code
Status: Needs review » Fixed

thanks for testing, I committed the fix to the entity api.

fago’s picture

Project: Entity cache » Entity API
Component: Code » Core integration

Status: Fixed » Closed (fixed)

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

Status: Closed (fixed) » Needs review

mrjavarava queued 4: entity_user.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 4: entity_user.patch, failed testing.