Bug 8397 - Can import patrons with duplicate userids
Summary: Can import patrons with duplicate userids
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Bugs List
QA Contact:
URL:
Keywords:
Depends on: 1861
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-09 19:29 UTC by Owen Leonard
Modified: 2016-02-17 13:27 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2012-07-09 19:29:02 UTC
If you use the "import patrons" tool to upload a CSV file of patron records it is possible to create more than one patron with the same userid. This should not be possible.
Comment 1 Katrin Fischer 2012-07-09 19:38:29 UTC
I also ran into this in the past. Linking to bug 1861.
Comment 2 Katrin Fischer 2014-04-18 09:45:32 UTC
Bumping severity on this, it's still a problem in current master. 

What I did was:
./misc/export_borrowers.pl -H -f borrowernumber -f cardnumber -f surname -f firstname -f categorycode -f dateenrolled -f expirydate -f sort1 -f sort2 -f sex -f branchcode >path/to/your/file.txt

Then I changed the file to add ,userid to the header and ,username to each of the patrons. The file reimported and updated patrons without any error. All patrons now have the same userid.
Comment 3 Jonathan Druart 2015-03-31 13:34:28 UTC
Should have been fixed by bug 1861.
Comment 4 Mason James 2016-02-17 12:17:07 UTC
(In reply to Owen Leonard from comment #0)
> If you use the "import patrons" tool to upload a CSV file of patron records
> it is possible to create more than one patron with the same userid. This
> should not be possible.

I also hit this bug today, when attempting to import/update patrons with undefined ("") userids
Comment 5 Jonathan Druart 2016-02-17 12:32:53 UTC
(In reply to Mason James from comment #4)
> (In reply to Owen Leonard from comment #0)
> > If you use the "import patrons" tool to upload a CSV file of patron records
> > it is possible to create more than one patron with the same userid. This
> > should not be possible.
> 
> I also hit this bug today, when attempting to import/update patrons with
> undefined ("") userids

Which versions? Do you have the unique key defined? (see bug 1861).
Comment 6 Mason James 2016-02-17 12:51:15 UTC
(In reply to Mason James from comment #4)
> (In reply to Owen Leonard from comment #0)
> > If you use the "import patrons" tool to upload a CSV file of patron records
> > it is possible to create more than one patron with the same userid. This
> > should not be possible.
> 
> I also hit this bug today, when attempting to import/update patrons with
> undefined ("") userids

i logged a new bug, as it is a little different from this one
 https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15840
Comment 7 Mason James 2016-02-17 12:54:02 UTC
(In reply to Jonathan Druart from comment #5)
> (In reply to Mason James from comment #4)
> > (In reply to Owen Leonard from comment #0)
> > > If you use the "import patrons" tool to upload a CSV file of patron records
> > > it is possible to create more than one patron with the same userid. This
> > > should not be possible.
> > 
> > I also hit this bug today, when attempting to import/update patrons with
> > undefined ("") userids
> 
> Which versions? Do you have the unique key defined? (see bug 1861).

version 3.18.9 to master

in my situation the unique key is '', which is a valid value hey?
Comment 8 Katrin Fischer 2016-02-17 13:20:26 UTC
I haven't seen this problem in recent vresions - maybe there is a twist to it. 
We have seen errors where users haven't been imported because the userid in the file was already in the database. - So that appears to be checked correctly. Also when the same userid was listed twice in one import file, only the first would be imported.
Comment 9 Mason James 2016-02-17 13:23:00 UTC
(In reply to Owen Leonard from comment #0)
> If you use the "import patrons" tool to upload a CSV file of patron records
> it is possible to create more than one patron with the same userid. This
> should not be possible.

I've confirmed that it's no longer possible to import duped useres, however the import tool now dies in some conditions

see bug 15840 for details
Comment 10 Mason James 2016-02-17 13:25:24 UTC
(In reply to Katrin Fischer from comment #8)
> I haven't seen this problem in recent vresions - maybe there is a twist to
> it. 
> We have seen errors where users haven't been imported because the userid in
> the file was already in the database. - So that appears to be checked
> correctly. Also when the same userid was listed twice in one import file,
> only the first would be imported.


i think the twist is that the bug is triggered when using the 'overwrite' import option, rather than 'ignore/skip'
Comment 11 Katrin Fischer 2016-02-17 13:27:19 UTC
Maybe it's some change since 3.18.x that we are using - because iirc that was with overwrite.