summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2015-08-26 03:15:26 (GMT)
committerwebchick2015-08-26 03:15:26 (GMT)
commitac15de319c2d1e4c9246802299b007db3be109ff (patch)
tree3ccca703960f43b0385c0dff7302ab10aa743c39
parent7d08e330faaf17492cea6d42eef0d7b46946cbf2 (diff)
Issue #2551631 by quietone, Ryan Weal, phenaproxima: D6 user_mail tokens do not get converted
-rw-r--r--core/modules/migrate_drupal/src/Tests/Table/d6/Variable.php14
-rw-r--r--core/modules/user/migration_templates/d6_user_mail.yml60
-rw-r--r--core/modules/user/src/Plugin/migrate/process/ConvertTokens.php51
-rw-r--r--core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php29
4 files changed, 117 insertions, 37 deletions
diff --git a/core/modules/migrate_drupal/src/Tests/Table/d6/Variable.php b/core/modules/migrate_drupal/src/Tests/Table/d6/Variable.php
index 79e6680..5144b31 100644
--- a/core/modules/migrate_drupal/src/Tests/Table/d6/Variable.php
+++ b/core/modules/migrate_drupal/src/Tests/Table/d6/Variable.php
@@ -695,6 +695,12 @@ class Variable extends DrupalDumpBase {
'name' => 'user_mail_register_no_approval_required_subject',
'value' => 's:38:"Account details for !username at !site";',
))->values(array(
+ 'name' => 'user_mail_register_pending_approval_body',
+ 'value' => "s:267:\"!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- !site team\";",
+ ))->values(array(
+ 'name' => 'user_mail_register_pending_approval_subject',
+ 'value' => 's:63:"Account details for !username at !site (pending admin approval)";',
+ ))->values(array(
'name' => 'user_mail_status_activated_body',
'value' => "s:419:\"!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n\";",
))->values(array(
@@ -719,12 +725,6 @@ class Variable extends DrupalDumpBase {
'name' => 'user_mail_status_deleted_subject',
'value' => 's:48:"Account details for !username at !site (deleted)";',
))->values(array(
- 'name' => 'user_mail_user_mail_register_pending_approval_body',
- 'value' => "s:267:\"!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- !site team\";",
- ))->values(array(
- 'name' => 'user_mail_user_mail_register_pending_approval_subject',
- 'value' => 's:63:"Account details for !username at !site (pending admin approval)";',
- ))->values(array(
'name' => 'user_register',
'value' => 'i:0;',
))->values(array(
@@ -734,4 +734,4 @@ class Variable extends DrupalDumpBase {
}
}
-#dd0717c35d3b181c80e5ad74ea2ed2f7
+#f34f009027a42145859ceca526d4c297
diff --git a/core/modules/user/migration_templates/d6_user_mail.yml b/core/modules/user/migration_templates/d6_user_mail.yml
index bc3badf..bc48dfd 100644
--- a/core/modules/user/migration_templates/d6_user_mail.yml
+++ b/core/modules/user/migration_templates/d6_user_mail.yml
@@ -15,25 +15,53 @@ source:
- user_mail_register_admin_created_body
- user_mail_register_no_approval_required_subject
- user_mail_register_no_approval_required_body
- - user_mail_user_mail_register_pending_approval_subject
- - user_mail_user_mail_register_pending_approval_body
+ - user_mail_register_pending_approval_subject
+ - user_mail_register_pending_approval_body
- user_mail_status_blocked_subject
- user_mail_status_blocked_body
process:
- 'status_activated/subject': user_mail_status_activated_subject
- 'status_activated/body': user_mail_status_activated_body
- 'password_reset/subject': user_mail_password_reset_subject
- 'password_reset/body': user_mail_password_reset_body
- 'cancel_confirm/subject': user_mail_status_deleted_subject
- 'cancel_confirm/body': user_mail_status_deleted_body
- 'register_admin_created/subject': user_mail_register_admin_created_subject
- 'register_admin_created/body': user_mail_register_admin_created_body
- 'register_no_approval_required/subject': user_mail_register_no_approval_required_subject
- 'register_no_approval_required/body': user_mail_register_no_approval_required_body
- 'register_pending_approval/subject': user_mail_user_mail_register_pending_approval_subject
- 'register_pending_approval/body': user_mail_user_mail_register_pending_approval_body
- 'status_blocked/subject': user_mail_status_blocked_subject
- 'status_blocked/body': user_mail_status_blocked_body
+ 'status_activated/subject':
+ plugin: convert_tokens
+ source: user_mail_status_activated_subject
+ 'status_activated/body':
+ plugin: convert_tokens
+ source: user_mail_status_activated_body
+ 'password_reset/subject':
+ plugin: convert_tokens
+ source: user_mail_password_reset_subject
+ 'password_reset/body':
+ plugin: convert_tokens
+ source: user_mail_password_reset_body
+ 'cancel_confirm/subject':
+ plugin: convert_tokens
+ source: user_mail_status_deleted_subject
+ 'cancel_confirm/body':
+ plugin: convert_tokens
+ source: user_mail_status_deleted_body
+ 'register_admin_created/subject':
+ plugin: convert_tokens
+ source: user_mail_register_admin_created_subject
+ 'register_admin_created/body':
+ plugin: convert_tokens
+ source: user_mail_register_admin_created_body
+ 'register_no_approval_required/subject':
+ plugin: convert_tokens
+ source: user_mail_register_no_approval_required_subject
+ 'register_no_approval_required/body':
+ plugin: convert_tokens
+ source: user_mail_register_no_approval_required_body
+ 'register_pending_approval/subject':
+ plugin: convert_tokens
+ source: user_mail_register_pending_approval_subject
+ 'register_pending_approval/body':
+ plugin: convert_tokens
+ source: user_mail_register_pending_approval_body
+ 'status_blocked/subject':
+ plugin: convert_tokens
+ source: user_mail_status_blocked_subject
+ 'status_blocked/body':
+ plugin: convert_tokens
+ source: user_mail_status_blocked_body
destination:
plugin: config
config_name: user.mail
diff --git a/core/modules/user/src/Plugin/migrate/process/ConvertTokens.php b/core/modules/user/src/Plugin/migrate/process/ConvertTokens.php
new file mode 100644
index 0000000..44da52f
--- /dev/null
+++ b/core/modules/user/src/Plugin/migrate/process/ConvertTokens.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Plugin\migrate\process\ConvertTokens.
+ */
+
+namespace Drupal\user\Plugin\migrate\process;
+
+use Drupal\migrate\MigrateException;
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\Row;
+
+/**
+ * Plugin to replace !tokens with [tokens].
+ *
+ * @MigrateProcessPlugin(
+ * id = "convert_tokens",
+ * handle_multiples = TRUE
+ * )
+ */
+class ConvertTokens extends ProcessPluginBase {
+
+ /**
+ * {@inheritdoc}
+ *
+ */
+ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+ $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' => '',
+ );
+
+ if (is_string($value)) {
+ return str_replace(array_keys($tokens), $tokens, $value);
+ }
+ else {
+ throw new MigrateException('Value must be a string.');
+ }
+ }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php b/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php
index b958943..6839515 100644
--- a/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php
+++ b/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php
@@ -33,20 +33,21 @@ class MigrateUserConfigsTest extends MigrateDrupal6TestBase {
*/
public function testUserMail() {
$config = $this->config('user.mail');
- $this->assertIdentical('Account details for !username at !site (approved)', $config->get('status_activated.subject'));
- $this->assertIdentical("!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n", $config->get('status_activated.body'));
- $this->assertIdentical('Replacement login information for !username at !site', $config->get('password_reset.subject'));
- $this->assertIdentical("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $config->get('password_reset.body'));
- $this->assertIdentical('Account details for !username at !site (deleted)', $config->get('cancel_confirm.subject'));
- $this->assertIdentical("!username,\n\nYour account on !site has been deleted.", $config->get('cancel_confirm.body'));
- $this->assertIdentical('An administrator created an account for you at !site', $config->get('register_admin_created.subject'));
- $this->assertIdentical("!username,\n\nA site administrator at !site has created an account for you. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $config->get('register_admin_created.body'));
- $this->assertIdentical('Account details for !username at !site', $config->get('register_no_approval_required.subject'));
- $this->assertIdentical("!username,\n\nThank you for registering at !site. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $config->get('register_no_approval_required.body'));
- $this->assertIdentical('Account details for !username at !site (pending admin approval)', $config->get('register_pending_approval.subject'));
- $this->assertIdentical("!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- !site team", $config->get('register_pending_approval.body'));
- $this->assertIdentical('Account details for !username at !site (blocked)', $config->get('status_blocked.subject'));
- $this->assertIdentical("!username,\n\nYour account on !site has been blocked.", $config->get('status_blocked.body'));
+
+ $this->assertIdentical('Account details for [user:name] at [site:name] (approved)', $config->get('status_activated.subject'));
+ $this->assertIdentical("[user:name],\n\nYour account at [site:name] has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password.\n\nOnce you have set your own password, you will be able to log in to [site:login-url] in the future using:\n\nusername: [user:name]\n", $config->get('status_activated.body'));
+ $this->assertIdentical('Replacement login information for [user:name] at [site:name]', $config->get('password_reset.subject'));
+ $this->assertIdentical("[user:name],\n\nA request to reset the password for your account has been made at [site:name].\n\nYou may now log in to [site:url-brief] by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password." , $config->get('password_reset.body'));
+ $this->assertIdentical('Account details for [user:name] at [site:name] (deleted)', $config->get('cancel_confirm.subject'));
+ $this->assertIdentical("[user:name],\n\nYour account on [site:name] has been deleted.", $config->get('cancel_confirm.body'));
+ $this->assertIdentical('An administrator created an account for you at [site:name]', $config->get('register_admin_created.subject'));
+ $this->assertIdentical("[user:name],\n\nA site administrator at [site:name] has created an account for you. You may now log in to [site:login-url] using the following username and password:\n\nusername: [user:name]\npassword: \n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password.\n\n\n-- [site:name] team", $config->get('register_admin_created.body'));
+ $this->assertIdentical('Account details for [user:name] at [site:name]', $config->get('register_no_approval_required.subject'));
+ $this->assertIdentical("[user:name],\n\nThank you for registering at [site:name]. You may now log in to [site:login-url] using the following username and password:\n\nusername: [user:name]\npassword: \n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password.\n\n\n-- [site:name] team", $config->get('register_no_approval_required.body'));
+ $this->assertIdentical('Account details for [user:name] at [site:name] (pending admin approval)', $config->get('register_pending_approval.subject'));
+ $this->assertIdentical("[user:name],\n\nThank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- [site:name] team", $config->get('register_pending_approval.body'));
+ $this->assertIdentical('Account details for [user:name] at [site:name] (blocked)', $config->get('status_blocked.subject'));
+ $this->assertIdentical("[user:name],\n\nYour account on [site:name] has been blocked.", $config->get('status_blocked.body'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get());
}