Bugzilla – Attachment 120769 Details for
Bug 28299
OpacHiddenItems not working in OPAC lists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28299: Make buildKohaItemsNamespace accept a Koha::Items resultset
Bug-28299-Make-buildKohaItemsNamespace-accept-a-Ko.patch (text/plain), 4.12 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-05-10 12:11:51 UTC
(
hide
)
Description:
Bug 28299: Make buildKohaItemsNamespace accept a Koha::Items resultset
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-05-10 12:11:51 UTC
Size:
4.12 KB
patch
obsolete
>From e534710bb012439b5a5b1f5420ea42ecce9a07ac Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 10 May 2021 09:03:31 -0300 >Subject: [PATCH] Bug 28299: Make buildKohaItemsNamespace accept a Koha::Items > resultset > >This patch makes buildKohaItemsNamespace (and its only caller, >XSLTParse4Display) accept a an optional Koha::Items resultset. > >This way we don't need to calculate (from the DB) the list of hidden >itemnumbers, but solve it in one query. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/XSLT.pm | 41 ++++++++++++++++++++++++----------------- > opac/opac-shelves.pl | 6 +++--- > 2 files changed, 27 insertions(+), 20 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 5aa0f7ce147..70c525b7c16 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -190,7 +190,7 @@ sub get_xslt_sysprefs { > } > > sub XSLTParse4Display { >- my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables ) = @_; >+ my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables, $items_rs ) = @_; > > $sysxml ||= C4::Context->preference($xslsyspref); > $xslfilename ||= C4::Context->preference($xslsyspref); >@@ -246,7 +246,7 @@ sub XSLTParse4Display { > if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" || $xslsyspref eq "XSLTResultsDisplay" ) { > $itemsxml = ""; #We don't use XSLT for items display on these pages > } else { >- $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); >+ $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items, $items_rs); > } > my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); > >@@ -289,28 +289,35 @@ sub XSLTParse4Display { > > =head2 buildKohaItemsNamespace > >-Returns XML for items. >+ my $items_xml = buildKohaItemsNamespace( $biblionumber, [ $hidden_items, $items ] ); >+ >+Returns XML for items. It accepts two optional parameters: >+- I<$hidden_items>: An arrayref of itemnumber values, for items that should be hidden >+- I<$items>: A Koha::Items resultset, for the items to be returned >+ >+If both parameters are passed, I<$items> is used as the basis resultset, and I<$hidden_items> >+are filtered out of it. >+ > Is only used in this module currently. > > =cut > > sub buildKohaItemsNamespace { >- my ($biblionumber, $hidden_items) = @_; >+ my ($biblionumber, $hidden_items, $items_rs) = @_; >+ >+ $hidden_items ||= []; >+ >+ my $query = {}; >+ $query = { 'me.itemnumber' => { not_in => $hidden_items } } >+ if $hidden_items; >+ >+ my $items; > >- if ( ref $hidden_items eq 'Koha::Items' ) { >- $items = $items->search( >- {}, >- { prefetch => [ 'branchtransfers', 'reserves' ] } >- ); >+ if ( $items_rs && ref($items_rs) eq 'Koha::Items' ) { >+ $items = $items_rs->search( $query, { prefetch => [ 'branchtransfers', 'reserves' ] } ); > } else { >- $hidden_items ||= []; >- >- $items = Koha::Items->search( >- { >- 'me.biblionumber' => $biblionumber, >- 'me.itemnumber' => { not_in => $hidden_items } >- { prefetch => [ 'branchtransfers', 'reserves' ] } >- ); >+ $query->{'me.biblionumber'} = $biblionumber; >+ $items = Koha::Items->search( $query, { prefetch => [ 'branchtransfers', 'reserves' ] } ); > } > > my $shelflocations = >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index d1783ca649c..e0303a6e707 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -366,9 +366,9 @@ if ( $op eq 'view' ) { > $this_item->{XSLTBloc} = XSLTParse4Display( > $biblionumber, $record, > "OPACXSLTListsDisplay", 1, >- $items, $sysxml, >- $xslfile, $lang, >- $variables >+ undef, $sysxml, >+ $xslfile, $lang, >+ $variables, $items->reset > ); > } > >-- >2.31.1
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 28299
:
120662
|
120756
|
120769
|
120792
|
120795
|
121018
|
121021
|
121022
|
121023
|
122050
|
122051
|
122052
|
122196
|
122197
|
122198
|
122593
|
122594
|
122595