Description of the problem
When importing member data from an XML file: if that member data includes a member_id tag, and if that id number matches the id number of an existing member, EE is supposed to overwrite the existing member with the new data (it gives a reminder about this beforehand). However, instead of overwriting the data, the import simply fails with an error.
How To Reproduce
Steps to reproduce the behaviour:
- Export some member data to XML in the standard EE 'member import' format, and include the member_id tag in each member's data.
- If necessary, edit the member_id tags in that data so that at least one matches the id number of an existing user in the system you are importing into.
- Proceed through the usual EE member import process (select the file, select a member group, etc). The import process will include a reminder that if you have member_id tags in your export data, you risk overwriting existing data. (It doesn't actually check whether the data file HAS such tags, it just presents the reminder/warning every time, just in case).
- The import process will fail (see error below).
Error Messages
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2' for key 'PRIMARY':
INSERT INTO `exp_members` (`group_id`, `member_id`, `username`, `screen_name`, `password`, `salt`, `email`, `ip_address`, `join_date`, `last_visit`, `language`, `timezone`, `time_format`, `date_format`, `include_seconds`, `unique_id`, `crypt_key`) VALUES (8, '2', 'Joe.Bloggs@example.com', 'Joe Bloggs', '49a0449454543c2f1bf2083d80466312fb26cae87a4d173cc09c9ffba4dc6d34d973787bd0e81238c891bfedc5a3a558c2773b3a33ad463c568c8a687b8357b5', 'yv\'aUq4MVT8\\S1X\"#!SC]L\'c{\'129!J6~]g0Sgk#VE#%)T-wsO#VjO%El?@cw)sSe?DoAq/G=0oY0+uDQ;s(I+?w\\J}~JfX!!mEK\\l?.j8hpvczJG(c0#Bi+bx@rArK>', 'Joe.Bloggs@example.com', '0.0.0.0', '1353667691', '1594633474', 'english', 'Europe/London', '12', '%j/%n/%Y', 'n', '42cc81e672a462b0d2dd22a25599196f437fdba1', 'a46062c31ae577c2640caf72c558d143512360b0')
ee/legacy/database/drivers/mysqli/mysqli_connection.php:117
Stack Trace: Please include when reporting this error
#0 ee/legacy/database/drivers/mysqli/mysqli_driver.php(112): CI_DB_mysqli_connection->query('INSERT INTO `ex...')
#1 ee/legacy/database/DB_driver.php(270): CI_DB_mysqli_driver->_execute('INSERT INTO `ex...')
#2 ee/legacy/database/DB_driver.php(180): CI_DB_driver->simple_query('INSERT INTO `ex...')
#3 ee/legacy/database/DB_active_rec.php(1371): CI_DB_driver->query('INSERT INTO `ex...')
#4 ee/EllisLab/ExpressionEngine/Service/Model/Query/Insert.php(75): CI_DB_active_record->insert('members')
#5 ee/EllisLab/ExpressionEngine/Service/Model/Query/Update.php(99): EllisLab\ExpressionEngine\Service\Model\Query\Insert->actOnGateway(Object(EllisLab\ExpressionEngine\Model\Member\Gateway\MemberGateway), Object(EllisLab\ExpressionEngine\Model\Member\Member))
#6 ee/EllisLab/ExpressionEngine/Service/Model/Query/Insert.php(39): EllisLab\ExpressionEngine\Service\Model\Query\Update->doWork(Object(EllisLab\ExpressionEngine\Model\Member\Member))
#7 ee/EllisLab/ExpressionEngine/Service/Model/Query/Insert.php(27): EllisLab\ExpressionEngine\Service\Model\Query\Insert->doWork(Object(EllisLab\ExpressionEngine\Model\Member\Member))
#8 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(282): EllisLab\ExpressionEngine\Service\Model\Query\Insert->run()
#9 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(238): EllisLab\ExpressionEngine\Service\Model\DataStore->runQuery('Insert', Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#10 ee/EllisLab/ExpressionEngine/Service/Model/Query/Builder.php(79): EllisLab\ExpressionEngine\Service\Model\DataStore->insertQuery(Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#11 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(360): EllisLab\ExpressionEngine\Service\Model\Query\Builder->insert()
#12 ee/EllisLab/ExpressionEngine/Model/Content/ContentModel.php(225): EllisLab\ExpressionEngine\Service\Model\Model->save()
#13 ee/EllisLab/ExpressionEngine/Controller/Utilities/MemberImport.php(751): EllisLab\ExpressionEngine\Model\Content\ContentModel->save()
#14 ee/EllisLab/ExpressionEngine/Controller/Utilities/MemberImport.php(421): EllisLab\ExpressionEngine\Controller\Utilities\MemberImport->doImport()
#15 [internal function]: EllisLab\ExpressionEngine\Controller\Utilities\MemberImport->processXml()
#16 ee/EllisLab/ExpressionEngine/Core/Core.php(268): call_user_func_array(Array, Array)
#17 ee/EllisLab/ExpressionEngine/Core/Core.php(118): EllisLab\ExpressionEngine\Core\Core->runController(Array)
#18 ee/EllisLab/ExpressionEngine/Boot/boot.php(156): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))
#19 public_html/admin.php(153): require_once('...')
#19 public_html/admin.php(153): require_once('...')
Screenshots / Videos / Template Code
None
Environment Details:
- Version: 5.4
- PHP Version 7.2.22
- MySQL Version 5.7.26
- OS: MacOS
- Web Server: MAMP 5.7
Possible Solution
Additional context
Removing the member_id tags from the XML file (OR simply removing those member(s) from the XML file whose member_id numbers conflict with pre-existing ids in the destination system) allows the import to proceed as expected, but without any data being overwritten. However, in some situations you might WANT specific member_ids to be overwritten with new data.
Description of the problem
When importing member data from an XML file: if that member data includes a member_id tag, and if that id number matches the id number of an existing member, EE is supposed to overwrite the existing member with the new data (it gives a reminder about this beforehand). However, instead of overwriting the data, the import simply fails with an error.
How To Reproduce
Steps to reproduce the behaviour:
Error Messages
Screenshots / Videos / Template Code
None
Environment Details:
Possible Solution
Additional context
Removing the member_id tags from the XML file (OR simply removing those member(s) from the XML file whose member_id numbers conflict with pre-existing ids in the destination system) allows the import to proceed as expected, but without any data being overwritten. However, in some situations you might WANT specific member_ids to be overwritten with new data.