Bug 28293

Summary: Wrong key used in Patrons::Import->generate_patron_attributes
Product: Koha Reporter: Jonathan Druart <jonathan.druart+koha>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart+koha>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: andrewfh, fridolin.somers, martin.renvoize, victor
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.06,20.05.12
Bug Depends on: 20443    
Bug Blocks: 28220    
Attachments: Bug 28293: (bug 20443 follow-up) Fix wrong key in Patrons::Import->generate_patron_attributes
Bug 28293: (bug 20443 follow-up) Fix wrong key in Patrons::Import->generate_patron_attributes

Description Jonathan Druart 2021-05-06 10:42:28 UTC
Caused by
  commit e37bfe3e4b395ef71a54c65226829248847cf1ce
  Bug 20443: Remove extended_attributes_code_value_arrayref AND C4::Members::Attributes

       sort { $a->{code} cmp $b->{code} || $a->{value} cmp $b->{value} }                                                                                                                                          
       map {                                                                                                                                                                                                      
         my @arr = split /:/, $_, 2;                                                                                                                                                                              
         { code => $arr[0], attribute => $arr[1] } 

First line must be 
      sort { $a->{code} cmp $b->{code} || $a->{attribute} cmp $b->{attribute} }
Comment 1 Jonathan Druart 2021-05-06 10:43:18 UTC
It generates warnings
Use of uninitialized value in string comparison (cmp) at /kohadevbox/koha/Koha/Patrons/Import.pm line 550, <$fh> line 2.                                      

And does not sort correctly (no fallback on the attribute's value for repeatable attributes)
Comment 2 Jonathan Druart 2021-05-06 10:47:08 UTC
Created attachment 120606 [details] [review]
Bug 28293: (bug 20443 follow-up) Fix wrong key in Patrons::Import->generate_patron_attributes

It generates warnings
Use of uninitialized value in string comparison (cmp) at /kohadevbox/koha/Koha/Patrons/Import.pm line 550, <$fh> line 2.

And does not sort correctly (no fallback on the attribute's value for repeatable attributes)
Comment 3 Jonathan Druart 2021-05-06 10:56:56 UTC
Tests on bug 28220 cover this (at least get rid of the warnings)

Test plan: Apply patches from bug 28220. Without this patch you see warnings.
Comment 4 Martin Renvoize 2021-05-11 08:05:22 UTC
Created attachment 120823 [details] [review]
Bug 28293: (bug 20443 follow-up) Fix wrong key in Patrons::Import->generate_patron_attributes

It generates warnings
Use of uninitialized value in string comparison (cmp) at /kohadevbox/koha/Koha/Patrons/Import.pm line 550, <$fh> line 2.

And does not sort correctly (no fallback on the attribute's value for repeatable attributes)

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2021-05-11 08:06:14 UTC
Clear fix, works as expected and squashes warnings.. Going straight for QA..
Comment 6 Jonathan Druart 2021-05-11 13:39:41 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 7 Fridolin Somers 2021-05-12 15:11:55 UTC
Pushed to 20.11.x for 20.11.06
Comment 8 Andrew Fuerste-Henry 2021-05-25 13:19:37 UTC
Pushed to 20.05.x for 20.05.12
Comment 9 Victor Grousset/tuxayo 2021-05-25 14:43:15 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.