Bugzilla – Attachment 75007 Details for
Bug 20702
Bind results of GetHostItemsInfo to the EasyAnalyticalRecords pref
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20702: Bind results of GetHostItemsInfo to the EasyAnalyticalRecords pref
Bug-20702-Bind-results-of-GetHostItemsInfo-to-the-.patch (text/plain), 3.46 KB, created by
Marcel de Rooy
on 2018-05-03 12:16:45 UTC
(
hide
)
Description:
Bug 20702: Bind results of GetHostItemsInfo to the EasyAnalyticalRecords pref
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-05-03 12:16:45 UTC
Size:
3.46 KB
patch
obsolete
>From f082d82675d534d281eda80ae139a4d615e65c85 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 3 May 2018 13:12:19 +0200 >Subject: [PATCH] Bug 20702: Bind results of GetHostItemsInfo to the > EasyAnalyticalRecords pref >Content-Type: text/plain; charset=utf-8 > >Triggered by the finding on bug 20697. >The three calls of GetHostItemsInfo should be controlled by the pref. This >patch makes the sub return an empty list when the pref is disabled. > >The patch simplifies the sub by merging the two identical foreach loops >depending on the field number in MARC21/UNIMARC. > >Will add a unit test on a follow-up patch. > >Test plan: >See next patch. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Items.pm | 62 +++++++++++++++++++++++++++++-------------------------------- > 1 file changed, 29 insertions(+), 33 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index e7279ff..bf464c3 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1206,44 +1206,40 @@ sub GetItemsLocationInfo { > > =head2 GetHostItemsInfo > >- $hostiteminfo = GetHostItemsInfo($hostfield); >- Returns the iteminfo for items linked to records via a host field >+ $hostiteminfo = GetHostItemsInfo($hostfield); >+ Returns the iteminfo for items linked to records via a host field > > =cut > > sub GetHostItemsInfo { >- my ($record) = @_; >- my @returnitemsInfo; >- >- if (C4::Context->preference('marcflavour') eq 'MARC21' || >- C4::Context->preference('marcflavour') eq 'NORMARC'){ >- foreach my $hostfield ( $record->field('773') ) { >- my $hostbiblionumber = $hostfield->subfield("0"); >- my $linkeditemnumber = $hostfield->subfield("9"); >- my @hostitemInfos = GetItemsInfo($hostbiblionumber); >- foreach my $hostitemInfo (@hostitemInfos){ >- if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ >- push (@returnitemsInfo,$hostitemInfo); >- last; >- } >- } >- } >- } elsif ( C4::Context->preference('marcflavour') eq 'UNIMARC'){ >- foreach my $hostfield ( $record->field('461') ) { >- my $hostbiblionumber = $hostfield->subfield("0"); >- my $linkeditemnumber = $hostfield->subfield("9"); >- my @hostitemInfos = GetItemsInfo($hostbiblionumber); >- foreach my $hostitemInfo (@hostitemInfos){ >- if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ >- push (@returnitemsInfo,$hostitemInfo); >- last; >- } >- } >- } >- } >- return @returnitemsInfo; >-} >+ my ($record) = @_; >+ my @returnitemsInfo; > >+ if( !C4::Context->preference('EasyAnalyticalRecords') ) { >+ return @returnitemsInfo; >+ } >+ >+ my @fields; >+ if( C4::Context->preference('marcflavour') eq 'MARC21' || >+ C4::Context->preference('marcflavour') eq 'NORMARC') { >+ @fields = $record->field('773'); >+ } elsif( C4::Context->preference('marcflavour') eq 'UNIMARC') { >+ @fields = $record->field('461'); >+ } >+ >+ foreach my $hostfield ( @fields ) { >+ my $hostbiblionumber = $hostfield->subfield("0"); >+ my $linkeditemnumber = $hostfield->subfield("9"); >+ my @hostitemInfos = GetItemsInfo($hostbiblionumber); >+ foreach my $hostitemInfo (@hostitemInfos) { >+ if( $hostitemInfo->{itemnumber} eq $linkeditemnumber ) { >+ push @returnitemsInfo, $hostitemInfo; >+ last; >+ } >+ } >+ } >+ return @returnitemsInfo; >+} > > =head2 GetLastAcquisitions > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20702
:
75007
|
75008
|
75194
|
75195
|
76197
|
76198