The documentation for the user_mail_tokens() function reads:

/**
* Return an array of token to value mappings for user e-mail messages.
*
* @param $account
*  The user object of the account being notified.  Must contain at
*  least the fields 'uid', 'name', and 'mail'.
* @param $language
*  Language object to generate the tokens with.
* @return
*  Array of mappings from token names to values (for use with strtr()).
*/

However, user_mail_tokens unconditionally calls user_pass_reset_url() which assumes the existence of 'pass' and 'login' fields, in order to set the '!login_url' token.

I can think of at least three possible fixes for this inconsistency:

  1. Revise the documentation to note the additional requirements of the 'pass' and 'login' fields.
  2. Set the '!login_url' token to url('user/login') if the 'pass' and 'login' fields are not supplied.
  3. Call user_load() if the 'pass' and 'login' fields are not supplied.

Three trivial patches attached; pick one.

Files: 
CommentFileSizeAuthor
#5 user_mail_tokens-fix_documentation-401266.patch955 bytesjhodgdon
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es).
[ View ]
#4 user_mail_tokens-remove_documentation-401266-4-d6.patch1.15 KBpillarsdotnet
#3 user_mail_tokens-fix_documentation-401266-3-d6.patch955 bytespillarsdotnet
#3 user_mail_tokens-verify_pass_login-401266-3-d6.patch1.07 KBpillarsdotnet
#3 user_mail_tokens-call_user_load-401266-3-d6.patch958 bytespillarsdotnet
user_mail_tokens-fix-3.diff583 bytespillarsdotnet
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch user_mail_tokens-fix-3.diff.
[ View ]
user_mail_tokens-fix-2.diff560 bytespillarsdotnet
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch user_mail_tokens-fix-2.diff.
[ View ]
user_mail_tokens-fix-1.diff440 bytespillarsdotnet
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch user_mail_tokens-fix-1.diff.
[ View ]

Comments

Title:E_ALL compliance in user_mail_tokens() functionDocumentation problem in user_mail_tokens() function
Component:user.module» documentation

This is a d6-only bug, because the documentation has been completely removed in d7. Perhaps the documentation should be likewise removed in d6?

Status:Needs review» Needs work

The last submitted patch, user_mail_tokens-fix-3.diff, failed testing.

(sigh)

Re-rolled all three for current d6 checkout.

A fourth possibility is to simply remove the documentation altogether, as it exists in d7/d8.

Status:Needs review» Reviewed & tested by the community
StatusFileSize
new955 bytes
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es).
[ View ]

Comment #4 - NO. We should instead document the function properly in D7/8. Our doc standards require @param and @return doc for all functions.

Original issue suggestions numbered 2 & 3 - these would be API functionality changes to Drupal 6, which at this point should be avoided.

So that leaves suggestion #1 - fix the doc.... You need to make patches without the -D6 extension so they can get tested (see help text below the attach field). But that aside, the first patch in comment #3 looks fine to me. I changed the name and re-uploaded it so it can be tested; provisionally setting to RTBC since it should be fine.

Title:Documentation problem in user_mail_tokens() functionuser_mail_tokens() doc is missing doc of required fields

Status:Reviewed & tested by the community» Fixed

Thanks, committed.

Status:Fixed» Closed (fixed)

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