Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
crashes with unknown error what email address has ' such as j.o'brien@somecompany.com
As I get also get the error
PDOException: in field_sql_storage_field_storage_write() (line 448 of /modules/field/modules/field_sql_storage/field_sql_storage.module).
It may also be falling over when any field has an ' in the data
Comments
Comment #1
chaloum CreditAttribution: chaloum commentedDont you think the function on line 293 of the user.inc file
function _user_import_existing_uid($email) {
$sql = 'SELECT uid FROM {users} WHERE mail = :mail';
$args = array(':mail' => $email);
$uid = db_query_range($sql, 0, 1, $args)->fetchField();
return $uid;
}
should be replaced with something like this
function _user_import_existing_uid($email) {
//Drupal 7
$uid='';
global $users;
$user=user_load_by_mail($email);
if(!empty($user)){
$uid=$user->uid;
}
return $uid;
}
Comment #2
Robert Castelo CreditAttribution: Robert Castelo commentedI can't reproduce this bug.
Added ' to an email address in the sample.txt, imported the file, user was created and import worked perfectly.
Could it be something else causing the issue?
We don't use user_load_by_mail($email) because that would load the whole User object, including firing off hook_user to bring in associated data, meaning it would be a big performance overhead just to check if an email exists in the email field.
Comment #3
chaloum CreditAttribution: chaloum commentedTry this
email,name,pass
d'monte@someaddress.com,D‰ÛªMonte,Password
I know it's a crazy name but is an actual example of a user name that was in a CSV of 5,00 users that I was given. Whilst I can understand that the there might be an issue the characters is should be normalising the data or at least failing gracefully with some easily understood info for the end user to fix.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, name, pass, mail, created, status, timezone, init, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => 11041 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => $S$D4fJC7IXVVU4yBrj/lFeKvideXgI.U8yI9rhLNqSrSfekQbdzkBQ [:db_insert_placeholder_3] => d'monte@someaddress.com [:db_insert_placeholder_4] => 1358643464 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => -18000 [:db_insert_placeholder_7] => d'monte@someaddress.com [:db_insert_placeholder_8] => a:1:{s:17:"mimemail_textonly";i:0;} ) in drupal_write_record() (line 7106 of /var/www/clients/client3/web42/web/includes/common.inc).
it would also be good if the user Import module could import taxonomy term reverence fields associated with the account
that being said I can manually create a user with the above details so the import user should also be able to do it.
P.S. event though the error says duplicate entry, there is in fact on duplicate entry.
Also regarding user_load_by_mail according the the documentation it only loads the user if found
"A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded."
So I'm not sure of the performance issue you are referring to, also later in the code you go on to use load_user_by_mail so why not here at line 293 and us it once?
Thanks
Comment #4
chaloum CreditAttribution: chaloum commentedBump
Comment #5
Simon Georges CreditAttribution: Simon Georges commentedChanging status, as there is no patch.
Comment #6
askibinski CreditAttribution: askibinski commentedI had the same PDO exception, which almost impossible to debug. I finally tracked down the rows which caused the error and found they had incompatible characters (non-utf-8).
The easiest way to fix this was by converting the csv to utf-8. You can do this in OpenOffice/ LibreOffice or just upload the csv in google drive (convert) and download as csv.
It would be nice though, if the test procedure would check vor non UTF-8 characters.
This should be pretty easy to do I think. Taken from stackoverflow:
Comment #7
garyconroy CreditAttribution: garyconroy commentedAlso getting a fall over when importing a user with the first name Éilish
Comment #8
gisleSingle quote (') works fine. As far as the issue summary goes, it is "Cannot reproduce".
As per #6, the real problem is characters in the file that are not UTF-8. The README.txt clearly spells out that the CSV-file must be saved as UTF-8.
Closing as duplicate of #813726: Non-ascii letters in users name or address truncates the rest.