Bug 20310: (follow-up) Add or remove orgcode in second try

We did remove an orgcode, but we could also do the other way
around.

Note: Hard to include in the unit test since it mocks the whole
search engine part.

Test plan:
[1] Run t/db_dependent/Koha/Biblio/host_record.t
[2] Test host 001 = number and child 773 = (org)number
[3] Test host 001 = (org)number and child 773 = number

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2020-09-08 12:59:53 +00:00 committed by Jonathan Druart
parent e5651d4dad
commit 1f8d0a8fe5

View file

@ -939,8 +939,14 @@ sub host_record {
$bibno = $engine->extract_biblionumber( $results->[0] );
last;
}
# Extract number from $w (remove orgcode) for second try
$rcn= $1 if $try == 1 && $rcn =~ /\)\s*(\d+)/;
# Add or remove orgcode for second try
if( $try == 1 && $rcn =~ /\)\s*(\d+)/ ) {
$rcn = $1; # number only
} elsif( $try == 1 && $rcn =~ /^\d+/ ) {
$rcn = "($orgcode)$rcn";
} else {
last;
}
}
if( $bibno ) {
my $host = Koha::Biblios->find($bibno) or return;