Bug 25189: Don't create authority if results found
Automatic authority creation assumes that if we don't match we need a new authority. Using the Default linker, however, we don't match if there exists more than one match. This leads to repeatedly generating authorities once there is a duplicate in the system We shoudl instead only create a new authority if there are no results To test: 1 - Set Linker Module to 'Default' 2 - Enable AutoCreateAuthorities and BiblioAddsAuthorities and CatalogModuleRelink and LinkerRelink 3 - Add two copies of a single authority via Z39 4 - Add a heading for that authority to a bib record 5 - Save the record and note a new authority is generated 6 - Repeat and see another is generated 7 - Apply patch 8 - Restart all the things 9 - Save the record again, no new authority created Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commit980419ed15) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> (cherry picked from commite5baeac0fd) Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
parent
e5f7075705
commit
bceeea6fa9
|
|
@ -578,7 +578,7 @@ sub LinkBibHeadingsToAuthorities {
|
|||
next;
|
||||
}
|
||||
|
||||
my ( $authid, $fuzzy ) = $linker->get_link($heading);
|
||||
my ( $authid, $fuzzy, $match_count ) = $linker->get_link($heading);
|
||||
if ($authid) {
|
||||
$results{ $fuzzy ? 'fuzzy' : 'linked' }
|
||||
->{ $heading->display_form() }++;
|
||||
|
|
@ -598,7 +598,7 @@ sub LinkBibHeadingsToAuthorities {
|
|||
if ( _check_valid_auth_link( $current_link, $field ) ) {
|
||||
$results{'linked'}->{ $heading->display_form() }++;
|
||||
}
|
||||
else {
|
||||
elsif ( !$match_count ) {
|
||||
my $authority_type = Koha::Authority::Types->find( $heading->auth_type() );
|
||||
my $marcrecordauth = MARC::Record->new();
|
||||
if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ sub get_link {
|
|||
my $auth_type = $heading->auth_type();
|
||||
my $authid;
|
||||
my $fuzzy = 0;
|
||||
my $match_count;
|
||||
|
||||
if ( $self->{'cache'}->{$search_form.$auth_type}->{'cached'} ) {
|
||||
$authid = $self->{'cache'}->{$search_form.$auth_type}->{'authid'};
|
||||
|
|
@ -42,6 +43,7 @@ sub get_link {
|
|||
|
||||
# look for matching authorities
|
||||
my $authorities = $heading->authorities(1); # $skipmetadata = true
|
||||
$match_count = scalar @$authorities;
|
||||
|
||||
if ( $behavior eq 'default' && $#{$authorities} == 0 ) {
|
||||
$authid = $authorities->[0]->{'authid'};
|
||||
|
|
@ -77,7 +79,7 @@ sub get_link {
|
|||
$self->{'cache'}->{$search_form.$auth_type}->{'authid'} = $authid;
|
||||
$self->{'cache'}->{$search_form.$auth_type}->{'fuzzy'} = $fuzzy;
|
||||
}
|
||||
return $self->SUPER::_handle_auth_limit($authid), $fuzzy;
|
||||
return $self->SUPER::_handle_auth_limit($authid), $fuzzy, $match_count;
|
||||
}
|
||||
|
||||
sub update_cache {
|
||||
|
|
|
|||
Loading…
Reference in New Issue