[Bug 44282] New: Import patrons reads columns by position, not by the header row, when a line has every column
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44282 Bug ID: 44282 Summary: Import patrons reads columns by position, not by the header row, when a line has every column Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: major Priority: P5 - low Component: Tools Assignee: koha-bugs@lists.koha-community.org Reporter: babarjunaid1122@gmail.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- Koha::Patrons::Import->import_patrons reads the header row, but for a line whose number of fields equals the number of importable columns it ignores the header and assigns the values by position: } elsif ( @columns == @columnkeys ) { @borrower{@columnkeys} = @columns; So a file with every column, but not in Koha's own order (columns moved in a spreadsheet, a file from another tool), is imported into the wrong fields, with no warning. Only files that leave out at least one column are read by the header. To reproduce (main): 1. ExtendedPatronAttributes = Don't enable. Take the full column list (the starter CSV on Tools > Import patrons) and swap the surname and firstname headers. 2. Add one line with surname "Headerorder", firstname "Swapped" (under their headers), a card number, a library and a category. 3. Import it: 1 imported, no error. The patron's surname is "Swapped" and the first name "Headerorder". 4. With ExtendedPatronAttributes = Enable (the file then has a patron_attributes column too), the same line is refused with an "unknown error": the positional branch turns the empty patron_attributes cell into undef and generate_patron_attributes dies ("Can't use an undefined value as an ARRAY reference", Import.pm line 452). Expected: the header row always decides which value goes to which field. Reproduced on main (c8e8025). -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44282 --- Comment #1 from babar junaid <babarjunaid1122@gmail.com> --- Created attachment 212593 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212593&action=edit Bug 44282: Import patrons: always read columns by the header row Bug 44282: Import patrons: always read columns by the header row When a line had exactly as many fields as there are importable columns, import_patrons assigned the values by position and ignored the header row. A file with every column in another order was imported into the wrong fields with no warning (surname and firstname swapped, for example), and with ExtendedPatronAttributes on the line died in generate_patron_attributes because the empty patron_attributes cell had become undef. The header row now decides for every line, as it already did for lines that leave a column out. Test plan: 1. prove t/db_dependent/Koha/Patrons/Import.t Without the patch the new subtest fails: surname and firstname are swapped with ExtendedPatronAttributes off, and the patron is not imported with it on. With the patch it passes. 2. Tools > Import patrons: download the starter CSV, swap the surname and firstname headers, add one patron (surname "Headerorder", firstname "Swapped", a card number, library and category), import. Without the patch the names are swapped; with it they are right. Sponsored-by: Koha Solutions -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44282 babar junaid <babarjunaid1122@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |babarjunaid1122@gmail.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org