Bug 23380

Summary: GuessAuthTypeCode should check authority type exists
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: CatalogingAssignee: Fridolin Somers <fridolin.somers>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: jonathan.druart, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 23380: GuessAuthTypeCode should check authority type exists
Bug 23380: GuessAuthTypeCode should check authority type exists

Description Fridolin Somers 2019-07-26 10:00:14 UTC
The method GuessAuthTypeCode is used when importing from batch or z3950/SRU to find the local authority type depending on MARC flavour and authority record fields.
This method should check that found type is configured.
Otherwise it can generate software errors when type code is used to fetch Koha::Authority::Type.
Comment 1 Fridolin Somers 2019-07-26 11:21:56 UTC
Created attachment 91797 [details] [review]
Bug 23380: GuessAuthTypeCode should check authority type exists

The method GuessAuthTypeCode is used when importing from batch or z3950/SRU to find the local authority type depending on MARC flavour and authority record fields.
This method should check that found type is configured.
Otherwise it can generate software errors when type code is used to fetch Koha::Authority::Type.

Test plan :
1) Delete an authority type, ie NP
2) Connect to a z3950/SRU authority server
3) Look for authorities of this type
4) Import an authority
5) Without patch you get error : Can't call method "auth_tag_to_report" on an undefined value at /home/koha/src/C4/AuthoritiesMarc.pm line 757.
6) With patch you see record edition and in logs "Authority type NP not configured"
Comment 2 Jonathan Druart 2019-11-26 15:35:49 UTC
Please cover subroutines changes by tests.
Comment 3 Fridolin Somers 2023-01-26 19:25:23 UTC
Created attachment 145703 [details] [review]
Bug 23380: GuessAuthTypeCode should check authority type exists

The method GuessAuthTypeCode is used when importing from batch or z3950/SRU to find the local authority type depending on MARC flavour and authority record fields.
This method should check that found type is configured.
Otherwise it can generate software errors when type code is used to fetch Koha::Authority::Type.

Test plan :
1) Delete an authority type, ie NP
2) Connect to a z3950/SRU authority server
3) Look for authorities of this type
4) Import an authority
5) Without patch you get error : Can't call method "auth_tag_to_report" on an undefined value at /home/koha/src/C4/AuthoritiesMarc.pm line 757.
6) With patch you see record edition and in logs "Authority type NP not configured"
Comment 4 Fridolin Somers 2023-01-26 19:27:56 UTC
Fixed for current master.

Using Koha::Authority::Types->search->get_column('authtypecode') is better.
Comment 5 Jonathan Druart 2023-01-31 15:42:20 UTC
(In reply to Fridolin Somers from comment #4)
> Fixed for current master.
> 
> Using Koha::Authority::Types->search->get_column('authtypecode') is better.

Which means? Do we close this one?
Comment 6 Fridolin Somers 2023-02-02 08:11:01 UTC
(In reply to Jonathan Druart from comment #5)
> (In reply to Fridolin Somers from comment #4)
> > Fixed for current master.
> > 
> > Using Koha::Authority::Types->search->get_column('authtypecode') is better.
> 
> Which means? Do we close this one?

No I mean rebased on current master and patch slightly changed