The upgrade from D6 to D7 went surprisingly smoothly for my site, but I was disappointed to find that the automated emails were not updated to use the new token system. So all of the automated emails still use tokens like !sitename instead of the new [site:name]. I have been going through and manually changing them but it's a wicked pain and I have had to do a bunch of playing to figure out the exact mapping.

I understand this could be potentially problematic if administrators had modified these automated messages, but in my case I had not and had to find out from some very confused users who got account activation and password recovery emails that included no relevant information.

It seems to me the best way to handle this is to see if the emails have been altered from their defaults in any way. If not, simply swap in the new D7 ones. If so, run a find/replace to swap the old D6 tokens for the new D7 tokens.

Leaving the site administrators to manually re-craft these 8 emails (and potentially more) does not seem like an adequate solution.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mail@victorquinn.com’s picture

BTW, I hope this ticket is in the right place. user system seemed like the closest component. There was no option for upgrade or email or anything else that seemed relevant in the list of Components.

Lars Toomre’s picture

Component: user system » token system

I agree that it is unreasonable to expect site administrators to have to change token formats for standard automated e-mail messages. This issue will bite more site administrators since I suspect that the bulk of production websites have not yet upgraded from D6 to Drupal 7.

In pseudo code, I would think the token_upgrade_d6_d7 function should do the following:
A. Get array mapping d6 tokens to d7 versions (at minimum should include all tokens in default d7 automated e-mail installation).
B. Initialize flag indicating whether more token updates needed.
C. Loop through all D6 automated e-mail messages.
C1. Loop through all token mappings and replace if d6 token version found.
C2. After token mapping loop, check if any D6 format tokens remain in mail message; set update flag if needed.
D. After message loop and if update token flag set, write appropriate message for display on administrator status page indicating that custom D6 tokens need to be updated. This message ideally then would open a page highlighting D6 tokens still need updating.

I have no clue though where in the D6 to D7 update process code this new function should be called. Changing the component to token so this might get more attention.

asimmonds’s picture

mail@victorquinn.com’s picture

The problem with just replacing the tokens as in http://drupal.org/node/1014262 or by the pseudocode you have Lars is that simply replacing the tokens is inadequate.

The D6 automated messages sent the user's password via plaintext. D7 does away with this. So not only is there no token for !password in D7, but the email would make little sense. For example, the D6 automated email for a new account says:

!username,

A site administrator at !site has created an account for you.

You may now log in to !login_uri using the following username and password:

username: !username
password: !password

...

If we just replace the tokens, a user will get an email that purports to tell them their password but has nothing there. This is horribly confusing for users and would require manual intervention. Hence the reason I suggested that during upgrade we check to see if the user still has the default (unmodified) D6 emails. If so, we can just wipe them and replace them with the new D7 appropriate ones. If not, do a token replacement but warn the user that their messages will need updating.

In my case it was quite embarrassing to get an email from a user wondering what the heck their account activation email meant. Turned out about a dozen had gone out like that before someone let me know. At a bare minimum, this issue ought to be mentioned in UPGRADE.txt.

Eric_A’s picture

Issue tags: +D7 upgrade path
Eric_A’s picture

Status: Active » Closed (duplicate)

Let's discuss this in one place. I've tagged this one and #1016502: Users doesn't receive the correct text when register (Migrated) as duplicate of #1014262: user_update_7011() completely broken (User email template tokens not upgraded), which was created earlier and has a patch.