diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info
index 15d2bfd..816d2ec 100644
--- a/modules/simpletest/simpletest.info
+++ b/modules/simpletest/simpletest.info
@@ -44,3 +44,4 @@ files[] = tests/upgrade/upgrade.node.test
 files[] = tests/upgrade/upgrade.taxonomy.test
 files[] = tests/upgrade/upgrade.upload.test
 files[] = tests/upgrade/upgrade.locale.test
+files[] = tests/upgrade/upgrade.user.test
diff --git a/modules/simpletest/tests/upgrade/drupal-6.user-no-password-token.database.php b/modules/simpletest/tests/upgrade/drupal-6.user-no-password-token.database.php
new file mode 100644
index 0000000..6463194
--- /dev/null
+++ b/modules/simpletest/tests/upgrade/drupal-6.user-no-password-token.database.php
@@ -0,0 +1,10 @@
+<?php
+db_insert('variable')->fields(array(
+  'name',
+  'value',
+))
+->values(array(
+  'name' => 'user_mail_register_no_approval_required_body',
+  'value' => 's:86:"!username, !site, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url.";',
+))
+->execute();
diff --git a/modules/simpletest/tests/upgrade/drupal-6.user-password-token.database.php b/modules/simpletest/tests/upgrade/drupal-6.user-password-token.database.php
new file mode 100644
index 0000000..367c704
--- /dev/null
+++ b/modules/simpletest/tests/upgrade/drupal-6.user-password-token.database.php
@@ -0,0 +1,10 @@
+<?php
+db_insert('variable')->fields(array(
+  'name',
+  'value',
+))
+->values(array(
+  'name' => 'user_mail_register_no_approval_required_body',
+  'value' => 's:97:"!password, !username, !site, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url.";',
+))
+->execute();
diff --git a/modules/simpletest/tests/upgrade/upgrade.user.test b/modules/simpletest/tests/upgrade/upgrade.user.test
new file mode 100644
index 0000000..6c66921
--- /dev/null
+++ b/modules/simpletest/tests/upgrade/upgrade.user.test
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Upgrade test for user.module (password token involved).
+ */
+class UserUpgradePathPasswordTokenTestCase extends UpgradePathTestCase {
+  public static function getInfo() {
+    return array(
+      'name'  => 'User upgrade path (password token involved)',
+      'description'  => 'User upgrade path tests (password token involved).',
+      'group' => 'Upgrade path',
+    );
+  }
+
+  public function setUp() {
+    // Path to the database dump files.
+    $this->databaseDumpFiles = array(
+      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
+      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.user-password-token.database.php',
+    );
+    parent::setUp();
+  }
+
+  /**
+   * Test a successful upgrade.
+   */
+  public function testUserUpgrade() {
+    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
+    $this->assertEqual(variable_get('user_mail_register_no_approval_required_body'), ', [user:name], [site:name], [site:url], [site:url-brief], [user:mail], [date:medium], [site:login-url], [user:edit-url], [user:one-time-login-url].', 'Existing email templates have been modified (password token involved).');
+  }
+}
+
+/**
+ * Upgrade test for user.module (password token not involved).
+ */
+class UserUpgradePathNoPasswordTokenTestCase extends UpgradePathTestCase {
+  public static function getInfo() {
+    return array(
+      'name'  => 'User upgrade path (password token not involved)',
+      'description'  => 'User upgrade path tests (password token not involved).',
+      'group' => 'Upgrade path',
+    );
+  }
+
+  public function setUp() {
+    // Path to the database dump files.
+    $this->databaseDumpFiles = array(
+      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
+      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.user-no-password-token.database.php',
+    );
+    parent::setUp();
+  }
+
+  /**
+   * Test a successful upgrade.
+   */
+  public function testUserUpgrade() {
+    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
+    $this->assertEqual(variable_get('user_mail_register_no_approval_required_body'), '[user:name], [site:name], [site:url], [site:url-brief], [user:mail], [date:medium], [site:login-url], [user:edit-url], [user:one-time-login-url].', 'Existing email templates have been modified (password token not involved).');
+  }
+}
diff --git a/modules/user/user.install b/modules/user/user.install
index 0967818..fb1e964 100644
--- a/modules/user/user.install
+++ b/modules/user/user.install
@@ -683,46 +683,13 @@ function user_update_7010() {
 }
 
 /**
- * Updates email templates to use new tokens.
+ * Placeholder function.
  *
- * This function upgrades customized email templates from the old !token format
- * to the new core tokens format. Additionally, in Drupal 7 we no longer e-mail
- * plain text passwords to users, and there is no token for a plain text
- * password in the new token system. Therefore, it also modifies any saved
- * templates using the old '!password' token such that the token is removed, and
- * displays a warning to users that they may need to go and modify the wording
- * of their templates.
+ * As a fix for user_update_7011() not updating email templates to use the new
+ * tokens, user_update_7017() now targets email templates of Drupal 6 sites and
+ * already upgraded sites.
  */
 function user_update_7011() {
-  $message = '';
-
-  $tokens = array(
-    '!site-name-token' => '[site:name]',
-    '!site-url-token' => '[site:url]',
-    '!user-name-token' => '[user:name]',
-    '!user-mail-token' => '[user:mail]',
-    '!site-login-url-token' => '[site:login-url]',
-    '!site-url-brief-token' => '[site:url-brief]',
-    '!user-edit-url-token' => '[user:edit-url]',
-    '!user-one-time-login-url-token' => '[user:one-time-login-url]',
-    '!user-cancel-url-token' => '[user:cancel-url]',
-    '!password' => '',
-  );
-
-  $result = db_select('variable', 'v')
-    ->fields('v', array('name', 'value'))
-    ->condition('value', db_like('user_mail_') . '%', 'LIKE')
-    ->execute();
-
-  foreach ($result as $row) {
-    if (empty($message) && (strpos($row->value, '!password') !== FALSE)) {
-      $message = t('The ability to send users their passwords in plain text has been removed in Drupal 7. Your existing email templates have been modified to remove it. You should <a href="@template-url">review these templates</a> to make sure they read properly.', array('@template-url' => url('admin/config/people/accounts')));
-    }
-
-    variable_set($row->name, str_replace(array_keys($tokens), $tokens, $row->value));
-  }
-
-  return $message;
 }
 
 /**
@@ -854,5 +821,52 @@ function user_update_7015() {
 }
 
 /**
+ * Update email templates to use new tokens.
+ *
+ * This function upgrades customized email templates from the old !token format
+ * to the new core tokens format. Additionally, in Drupal 7 we no longer e-mail
+ * plain text passwords to users, and there is no token for a plain text
+ * password in the new token system. Therefore, it also modifies any saved
+ * templates using the old '!password' token such that the token is removed, and
+ * displays a warning to users that they may need to go and modify the wording
+ * of their templates.
+ */
+function user_update_7017() {
+  $message = '';
+
+  $tokens = array(
+    '!site' => '[site:name]',
+    '!username' => '[user:name]',
+    '!mailto' => '[user:mail]',
+    '!login_uri' => '[site:login-url]',
+    '!uri_brief' => '[site:url-brief]',
+    '!edit_uri' => '[user:edit-url]',
+    '!login_url' => '[user:one-time-login-url]',
+    '!uri' => '[site:url]',
+    '!date' => '[date:medium]',
+    '!password' => '',
+  );
+
+  $result = db_select('variable', 'v')
+    ->fields('v', array('name'))
+    ->condition('name', db_like('user_mail_') . '%', 'LIKE')
+    ->execute();
+
+  foreach ($result as $row) {
+    // Use variable_get() to get the unserialized value for free.
+    if ($value = variable_get($row->name, FALSE)) {
+
+      if (empty($message) && (strpos($value, '!password') !== FALSE)) {
+        $message = t('The ability to send users their passwords in plain text has been removed in Drupal 7. Your existing email templates have been modified to remove it. You should <a href="@template-url">review these templates</a> to make sure they read properly.', array('@template-url' => url('admin/config/people/accounts')));
+      }
+
+      variable_set($row->name, str_replace(array_keys($tokens), $tokens, $value));
+    }
+  }
+
+  return $message;
+}
+
+/**
  * @} End of "addtogroup updates-6.x-to-7.x"
  */
