From 1f8d0a8fe5dd99ce072d184baab875e568a9b8cd Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 8 Sep 2020 12:59:53 +0000 Subject: [PATCH] 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 Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- Koha/Biblio.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 76efc062b3..3b38a82ce0 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -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; -- 2.39.5