From afdc4f42bb29172daf286bfe92810b3341779dfe 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 Content-Type: text/plain; charset=utf-8 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 --- Koha/Biblio.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 6b4a21ef0f..468591c66e 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -864,8 +864,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.11.0