Bugzilla – Attachment 145703 Details for
Bug 23380
GuessAuthTypeCode should check authority type exists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23380: GuessAuthTypeCode should check authority type exists
Bug-23380-GuessAuthTypeCode-should-check-authority.patch (text/plain), 2.33 KB, created by
Fridolin Somers
on 2023-01-26 19:25:23 UTC
(
hide
)
Description:
Bug 23380: GuessAuthTypeCode should check authority type exists
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2023-01-26 19:25:23 UTC
Size:
2.33 KB
patch
obsolete
>From c0dc54cbf227d4a64a5d0899dae5003e2c7fd285 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Fri, 26 Jul 2019 12:01:37 +0200 >Subject: [PATCH] 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" >--- > C4/AuthoritiesMarc.pm | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 0a2a736493..099553817c 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -21,6 +21,7 @@ package C4::AuthoritiesMarc; > use strict; > use warnings; > use MARC::Field; >+use List::MoreUtils qw(any); > > use C4::Context; > use C4::Biblio qw( GetFrameworkCode ModBiblio ); >@@ -425,8 +426,19 @@ sub GuessAuthTypeCode { > '280'=>{authtypecode=>'GENRE/FORM'}, > } > }; >- foreach my $field (keys %{$heading_fields->{uc(C4::Context->preference('marcflavour'))} }) { >- return $heading_fields->{uc(C4::Context->preference('marcflavour'))}->{$field}->{'authtypecode'} if (defined $record->field($field)); >+ my $marcflavour = uc( C4::Context->preference('marcflavour') ); >+ my @authtypecodes = Koha::Authority::Types->search->get_column('authtypecode'); >+ foreach my $field ( keys %{ $heading_fields->{$marcflavour} } ) { >+ if ( defined $record->field($field) ) { >+ my $authtypecode = $heading_fields->{$marcflavour}->{$field}->{'authtypecode'}; >+ if ( any { $authtypecode eq $_ } @authtypecodes ) { >+ return $authtypecode; >+ } >+ else { >+ warn "Authority type $authtypecode not configured"; >+ return; >+ } >+ } > } > return; > } >-- >2.39.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23380
:
91797
| 145703