For those modules that override theme_user_picture, views with user picture fields can become problematic because instead of a fully-loaded user object, the data that we get is a partially and manually created user account data with just uid, name and picture. If we need to check the account object against a certain permission (such as the case with the Gravatar module), we have to perform a reload of the user object. It would seem more correct that the fully-loaded user object should be provided with the field handler.

CommentFileSizeAuthor
#1 491082.patch1.04 KBdave reid

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

Attached patch works for me locally, but I'm not sure if the user_load operation should happen sooner than this level. At least with this, a fully loaded user object is provided to theme('user_picture').

dave reid’s picture

The Gravatar bug report that I should reference is at #460662: Multiple warning with gravatar in OG faces.

merlinofchaos’s picture

Performing a user_load() is really bad for performance and I am highly resistant to doing this.

dawehner’s picture

Perhaps gravatar could perform a hook_views_data_alter and change the handler of the user picture, to load all what gravatar needs.

But i think with a changed handler you also don't need a full user_load

merlinofchaos’s picture

Status: Needs review » Closed (won't fix)

Also note that theme('user_picture') is also often called with a node, that only includes selected fields from the linked user. I think I will not fix this in Views. As dereine says, Gravatar can use views_data_alter and change the handler if it's really important.

dave reid’s picture

Yeah I agree with the solution for now. The issue with nodes and comments provided incomplete data has also bugged me and I'm probably going to work on a core patch that uses $node->account and $comment->account and provides full user account objects to theme('user_picture', ...).