From ecef74cf77837e503f176ef7909bcbeb8adcdfbb Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 15 Sep 2023 13:55:07 +0000 Subject: [PATCH] Bug 26314: (QA follow-up) Improve POD and fix links for UseControlNumber off When UseControlNumber is off, we previously did a search on the title index, but this was not actually correct. It might work when we have a dependent title and the title also appears on 245$p, but there is a better way: The title of the set record will be found in: * 773$3 for a dependent title * 800/810/811/830 for an independent title The search indices to use are host-item and title-series. As we are not only looking for 773, POD was adjusted to reflect that. Signed-off-by: Katrin Fischer --- Koha/Biblio.pm | 10 ++++++---- .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 3 ++- .../bootstrap/en/xslt/MARC21slim2OPACDetail.xsl | 3 ++- t/db_dependent/Koha/Biblio.t | 7 ++++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 3e3e0f0759..7f59056d30 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -720,7 +720,7 @@ sub get_components_query { my $volumes = $self->get_marc_volumes(); Returns an array of MARCXML data, which are volumes parts of -this object (MARC21 773$w points to this) +this object (MARC21 773$w or 8xx$w point to this) =cut @@ -759,6 +759,7 @@ sub get_volumes_query { # Only build volumes query if we're in a 'Set' record # or we have a monographic series. + # For monographic series the check on LDR 7 in (b or i or s) is omitted my $leader19 = substr( $marc->leader, 19, 1 ); my $pf008 = $marc->field('008') || ''; my $mseries = ( $pf008 && substr( $pf008->data(), 21, 1 ) eq 'm' ) ? 1 : 0; @@ -776,12 +777,12 @@ sub get_volumes_query { if ( !defined($pf003) ) { - # search for 773$w='Host001' + # search for linking_field$w='Host001' $searchstr .= "rcn:" . $pf001->data(); } else { $searchstr .= "("; - # search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001' + # search for (linking_field$w='Host001' and 003='Host003') or linking_field$w='(Host003)Host001' $searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")"; $searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\""; $searchstr .= ")"; @@ -795,7 +796,8 @@ sub get_volumes_query { my $cleaned_title = $marc->subfield( '245', "a" ); $cleaned_title =~ tr|/||; $cleaned_title = $builder->clean_search_term($cleaned_title); - $searchstr = "ti,phr:($cleaned_title)"; + $searchstr = qq#(title-series,phr:("$cleaned_title") OR Host-item,phr:("$cleaned_title")#; + $searchstr .= " NOT (bib-level:a OR bib-level:b))"; } return $searchstr; diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index e4f1719fc7..4428d3f6ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -232,6 +232,7 @@ + Volumes: @@ -240,7 +241,7 @@ /cgi-bin/koha/catalogue/search.pl?q=rcn:+NOT+(bib-level:a+OR+bib-level:b) - /cgi-bin/koha/catalogue/search.pl?q=ti,phr: + /cgi-bin/koha/catalogue/search.pl?q=title-series,phr:""+OR+host-item,phr=""+NOT+(bib-level:a+OR+bib-level:b) Show volumes diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl index 842f52e79e..047d56eae1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl @@ -274,6 +274,7 @@ + Volumes: @@ -282,7 +283,7 @@ /cgi-bin/koha/opac-search.pl?q=rcn:+NOT+(bib-level:a+OR+bib-level:b) - /cgi-bin/koha/opac-search.pl?q=ti,phr: + /cgi-bin/koha/opac-search.pl?q=ti,phr:""+OR+host-item,phr=""+NOT+(bib-level:a+OR+bib-level:b) Show volumes diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 87e917e7af..e88c6c3cb8 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -630,7 +630,11 @@ subtest 'get_volumes_query' => sub { $biblio = Koha::Biblios->find( $biblio->biblionumber ); t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); - is( $biblio->get_volumes_query, "ti,phr:(Some boring read)", "UseControlNumber disabled" ); + is( + $biblio->get_volumes_query, + "(title-series,phr:(\"Some boring read\") OR Host-item,phr:(\"Some boring read\") NOT (bib-level:a OR bib-level:b))", + "UseControlNumber disabled" + ); t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); my $marc_001_field = MARC::Field->new( '001', $biblionumber ); @@ -638,6 +642,7 @@ subtest 'get_volumes_query' => sub { C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); $biblio = Koha::Biblios->find( $biblio->biblionumber ); + is( $biblio->get_volumes_query, "(rcn:$biblionumber NOT (bib-level:a OR bib-level:b))", "UseControlNumber enabled without MarcOrgCode" -- 2.30.2