From f56e6c0a58145ed3a30341bf0df85e17cde0135d Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Thu, 20 Oct 2011 15:54:07 -0400 Subject: [PATCH] Bug 7073: GetCOinSBiblio should take $record object, not biblionumber This patch changes the GetCOinsBiblio subroutine to take a MARC record object (as returned from GetMarcBiblio) instead of a biblionumber. The first thing the subroutine did was GetMarcBiblio, and the $biblionumber passed was never used again. This subroutine was only used 3 places: opac/opac-search.pl, opac/opac-detail.pl, and C4/VirtualShelves/Page.pm. In the first and last cases, it was used in a loop. In the last two cases, a call to GetMarcBiblio had already been done. This is expensive, and we were doing it twice per record. For opac/opac-search.pl, the call to GetMarcBiblio was moved to just outside GetCOinSBiblio; this will not change the performance at all. But for opac/opac-detail.pl and C4/VirtualShelves/Page.pm, a redudant call to GetMarcBiblio is now avoided. To Test: 1. Enable COinSinOPACResults in system preferences. Perform a search in the OPAC. Verify that the COinS spans are showing up 2. View the detail record of one of the returned items. Confirm that the COinS span exists on the detail page. 3. View a list in the OPAC. Confirm that COinS spans are still showing up Signed-off-by: Chris Cormack Signed-off-by: Paul Poulain --- C4/Biblio.pm | 9 +++------ C4/VirtualShelves/Page.pm | 2 +- opac/opac-detail.pl | 2 +- opac/opac-search.pl | 3 ++- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index a112c84757..52119ea990 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1104,20 +1104,17 @@ sub GetXmlBiblio { =head2 GetCOinSBiblio - my $coins = GetCOinSBiblio($biblionumber); + my $coins = GetCOinSBiblio($record); -Returns the COinS(a span) which can be included in a biblio record +Returns the COinS (a span) which can be included in a biblio record =cut sub GetCOinSBiblio { - my ($biblionumber) = @_; - my $record = GetMarcBiblio($biblionumber); + my $record = shift; # get the coin format if ( ! $record ) { - # can't get a valid MARC::Record object, bail out at this point - warn "We called GetMarcBiblio with a biblionumber that doesn't exist biblionumber=$biblionumber"; return; } my $pos7 = substr $record->leader(), 7, 1; diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index 8a171821b7..18535a5724 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -217,7 +217,7 @@ sub shelfpage ($$$$$) { #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'}; $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} ); $this_item->{'imageurl'} = getitemtypeinfo( $this_item->{'itemtype'} )->{'imageurl'}; - $this_item->{'coins'} = GetCOinSBiblio( $this_item->{'biblionumber'} ); + $this_item->{'coins'} = GetCOinSBiblio( $record ); $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'})); $this_item->{'normalized_upc'} = GetNormalizedUPC( $record,$marcflavour); $this_item->{'normalized_ean'} = GetNormalizedEAN( $record,$marcflavour); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index d3c7e2a15f..e2fb0691cd 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -599,7 +599,7 @@ $template->param( # COinS format FIXME: for books Only $template->param( - ocoins => GetCOinSBiblio($biblionumber), + ocoins => GetCOinSBiblio($record), ); my $libravatar_enabled = 0; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 716b16413b..42eb0ecc78 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -506,7 +506,8 @@ for (my $i=0;$i<@servers;$i++) { } if (C4::Context->preference('COinSinOPACResults')) { foreach (@newresults) { - $_->{coins} = GetCOinSBiblio($_->{'biblionumber'}); + my $record = GetMarcBiblio($_->{'biblionumber'}); + $_->{coins} = GetCOinSBiblio($record); } } -- 2.39.5