Bugzilla – Attachment 129101 Details for
Bug 29802
biblionumber in OPACHiddenItems breaks opac lists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29802: add 'me' to filter_by_visible_in_opac query
Bug-29802-add-me-to-filterbyvisibleinopac-query.patch (text/plain), 3.78 KB, created by
Nick Clemens (kidclamp)
on 2022-01-06 16:18:57 UTC
(
hide
)
Description:
Bug 29802: add 'me' to filter_by_visible_in_opac query
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-01-06 16:18:57 UTC
Size:
3.78 KB
patch
obsolete
>From 76947f88da7a00b7e01784484683b1bc7388de0e Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 6 Jan 2022 16:03:56 +0000 >Subject: [PATCH] Bug 29802: add 'me' to filter_by_visible_in_opac query > >This patch prefixes all of the fields in OpacHiddenItems with >"me." before searching. > >Unit tests added to cover this case1 > >To test: >1 - Create a public list >2 - Set OpacHiddenItems to: > biblionumber: [1] >3 - Attempt to view list in OPAC >4 - Booom >5 - Aply patch >6 - Reload list >7 - Success >--- > Koha/Items.pm | 2 +- > t/db_dependent/Koha/Items.t | 9 ++++++++- > t/db_dependent/XSLT.t | 14 +++++++++++++- > 3 files changed, 22 insertions(+), 3 deletions(-) > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 0730935a0b..9a5db96af4 100644 >--- a/Koha/Items.pm >+++ b/Koha/Items.pm >@@ -127,7 +127,7 @@ sub filter_by_visible_in_opac { > > my $rules_params; > foreach my $field ( keys %$rules ) { >- $rules_params->{$field} = >+ $rules_params->{'me.'.$field} = > [ { '-not_in' => $rules->{$field} }, undef ]; > } > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index dc258b4510..4390728917 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -1587,7 +1587,7 @@ $schema->storage->txn_rollback; > > subtest 'filter_by_visible_in_opac() tests' => sub { > >- plan tests => 12; >+ plan tests => 13; > > $schema->storage->txn_begin; > >@@ -1688,6 +1688,13 @@ subtest 'filter_by_visible_in_opac() tests' => sub { > 'No rules passed, hidelostitems set, patron exception changes nothing' > ); > >+ $rules = { biblionumber => [ $biblio->biblionumber ] }; >+ is( >+ $biblio->items->filter_by_visible_in_opac->count, >+ 0, >+ 'Biblionumber rule successfully hides all items' >+ ); >+ > $rules = { withdrawn => [ 1, 2 ], copynumber => [ 2 ] }; > is( > $biblio->items->filter_by_visible_in_opac->count, >diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t >index 9cda1c5b8c..1e25c6dbb2 100755 >--- a/t/db_dependent/XSLT.t >+++ b/t/db_dependent/XSLT.t >@@ -147,11 +147,12 @@ $schema->storage->txn_rollback; > > subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { > >- plan tests => 20; >+ plan tests => 23; > > $schema->storage->txn_begin; > > my $biblio = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; > > # Have two known libraries for testing purposes > my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); >@@ -174,6 +175,17 @@ subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { > like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' ); > like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); > unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); >+ >+ my $mocked_context = Test::MockModule->new('C4::Context'); >+ $mocked_context->mock( 'yaml_preference', sub { >+ return { biblionumber => [ $biblio2->biblionumber ] }; >+ }); >+ my $hid_rs = $biblio->items->search({ "me.itemnumber" => { '!=' => $item_3->itemnumber } })->filter_by_visible_in_opac(); >+ $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, undef, $hid_rs ); >+ like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' ); >+ like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); >+ unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); >+ > ## Test passing one item in hidden_items and items_rs > $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $items_rs->reset ); > >-- >2.30.2
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 29802
:
129101
|
131099
|
131911
|
131912
|
131970
|
131971