diff --git a/commands/sql/sync.sql.inc b/commands/sql/sync.sql.inc index 2b718a3..73f5fdd 100644 --- a/commands/sql/sync.sql.inc +++ b/commands/sql/sync.sql.inc @@ -116,10 +116,10 @@ function sql_drush_sql_sync_sanitize($site) { $email_map = array('%uid' => "', uid, '", '%mail' => "', replace(mail, '@', '_'), '", '%name' => "', replace(name, ' ', '_'), '"); $newmail = "concat('" . str_replace(array_keys($email_map), array_values($email_map), $newemail) . "')"; } - $user_table_updates[] = "mail = $newmail"; + $user_table_updates[] = "mail = $newmail, init = $newmail"; } else { - $user_table_updates[] = "mail = '$newemail'"; + $user_table_updates[] = "mail = '$newemail', init = '$newmail'"; } $message_list[] = 'email addresses'; } @@ -127,6 +127,11 @@ function sql_drush_sql_sync_sanitize($site) { if (!empty($user_table_updates)) { $sanitize_query = "UPDATE users SET " . implode(', ', $user_table_updates) . " WHERE uid > 0;"; drush_sql_register_post_sync_op('user-email', dt('Reset !message in user table', array('!message' => implode(' and ', $message_list))), $sanitize_query); + + // Sanitize email addresses in the init and name columns. + if ($newemail != 'no') { + drush_sql_register_post_sync_op('user-name', dt('Reset email based names in user table'), "UPDATE users SET name = mail WHERE name LIKE '%@%';"); + } } // Seems quite portable (SQLite?) - http://en.wikipedia.org/wiki/Truncate_(SQL)