Problem/Motivation
The doc header for template_preprocess_user() says that $variables contains $account.
$variables actually contains a render element called 'elements'.
API pages:
https://api.drupal.org/api/drupal/core%21modules%21user%21user.pages.inc... (D8)
http://api.drupal.org/api/drupal/modules--user--user.pages.inc/function/... (D7)
Proposed resolution
Update the documentation in 8.x, then backport to 7.x. template_preprocess_taxonomy_term() has a good example of documenting 'elements'.
Visit /user and debug within template_preprocess_user() to get the important keys of the elements array.
Remaining tasks
| Task | Novice task? | Contributor instructions | Complete? |
|---|---|---|---|
| Create a patch | Yes | Instructions | No |
User interface changes
n/a
API changes
n/a
Original report by @jhodgdon
API page: http://api.drupal.org/api/drupal/modules--user--user.pages.inc/function/...
Describe the problem you have found:
The doc header for this function says that $variables contains $account.
That is not correct. I'm not sure what it should say, but not that.
Comments
Comment #1
star-szrtemplate_preprocess_user_profile was moved to template_preprocess_user in 8.x via #1857324: Use default theme name and entity key in $build for user entity. Updating the issue summary.
Comment #2
star-szrComment #3
star-szrRestoring original summary that I accidentally deleted.
Comment #4
star-szrBeing noisy.
Comment #5
pushpinderchauhan commentedI would debug this issue and contribute the patch soon.
Comment #6
pushpinderchauhan commentedCheckout $variables array and updated the documentation accordingly in this patch.
Comment #7
jhodgdonLooks correct to me, thanks!
The only problem is line length. No line of documentation should be longer than 80 characters, including the spaces and * at the front.
Comment #8
pushpinderchauhan commentedPlease review this patch.
Comment #9
star-szrIt looks like we have some tabs in here which don't match standards: https://drupal.org/coding-standards#indenting. Documentation lines should also be as long as possible within the 80 character limit so some of the "The user account of the profile being viewed" text should be on the same line as the \Drupal\user\Entity\User text. Ref: https://drupal.org/node/1354#drupal
Comment #10
pushpinderchauhan commentedThanks @Cottser, its a late night here so did this mistake :)
Removed unwanted tab in this patch, please review once.
Comment #11
star-szrGetting closer!
These shouldn't be separate bullets, it should look more like:
(totally guessing at what would fit, you'll need to check to make sure the first line fits within 80 characters).
Comment #12
pushpinderchauhan commented@Cottser, thank you for your feedback. here is next patch where #user line not exceeding 80 characters. Please review.
Comment #13
star-szrLooks good to me, thanks @er.pushpinderrana :)
Comment #15
jhodgdonThanks for the patches and reviews! Looks good to me too. Committed to 8.x.
Comment #16
jhodgdonOh wait, looks like this needs a port to D7. I tried the patch, doesn't apply, and we also need to modify it for 7 (the user object is not the same class, for instance, and we need to check and make sure the same components are being used too).
Comment #17
pushpinderchauhan commentedsorry for delay.
Checkout $variables array and updated the documentation for D7. Please review.
Comment #18
star-szrThanks @er.pushpinderrana! Needs a couple touch-ups:
The line starting with "fields" and the one after it are indented by one space too many, they should line up with "elements:".
The 'user' variable is part of _template_preprocess_default_variables() so shouldn't be included here.
Comment #19
pushpinderchauhan commentedThanks @Cottser, completed #1 and #2.
Please review.
Comment #20
jhodgdonLooking pretty good, thanks!
Can we change the first line to say @param $variables instead, and then add a next line like we have in the Drupal 8 version please?
Comment #21
pushpinderchauhan commented@jhodgdon thanks for your valuable feedback!
Please review this patch, made your suggested changes.
Comment #22
star-szrSo close!
We need to indent the #account line because #account is a key of the elements array. Compare to the D8 patch to see what I mean.
Comment #23
amitgoyal commentedPlease review updated patch for fixes in #22.
Comment #24
jhodgdonI think that's it, thanks!
Comment #25
star-szr+1, looks good.
Comment #28
star-szrLooks like we had a random/unrelated failure, back to RTBC. Thanks for the retest @mgifford :)
Comment #29
mgiffordThere have been a lot of them lately. Glad to help nudge this along.
Comment #32
jhodgdonComment #33
jhodgdonThanks again! Committed to 7.x.