Bugzilla – Attachment 194446 Details for
Bug 40481
The items table on koha/opac-MARCdetail.pl does not honor OPACHiddenItems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40481: Fix OPAC MARC detail showing hidden items
cafeb95.patch (text/plain), 2.25 KB, created by
Tomás Cohen Arazi (tcohen)
on 2026-03-04 13:18:58 UTC
(
hide
)
Description:
Bug 40481: Fix OPAC MARC detail showing hidden items
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2026-03-04 13:18:58 UTC
Size:
2.25 KB
patch
obsolete
>From cafeb9528068d4d2de7ba167829cc19f35f1693c Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Wed, 4 Mar 2026 10:11:43 -0300 >Subject: [PATCH] Bug 40481: Fix OPAC MARC detail showing hidden items > >The OPAC MARC detail view (opac-MARCdetail.pl) uses $record->fields() >to build the items table. This pulls item fields from the embedded MARC >record, bypassing the OPACHiddenItems filtering done by >filter_by_visible_in_opac. > >This patch replaces the $record->fields() call with the already-filtered >$items resultset, converting each Koha::Item back to a MARC::Field via >as_marc_field. > >Test plan: >1. Apply patch, do not restart plack yet >2. Setup: > $ ktd --shell > k$ koha-mysql kohadev <<< "UPDATE systempreferences SET value = 'damaged: [1]' WHERE variable = 'OpacHiddenItems';" > k$ koha-mysql kohadev <<< "UPDATE items SET damaged = 1 WHERE biblionumber = 416 LIMIT 1;" > k$ flush_memcached >3. Point your browser to the OPAC MARC detail view: > http://kohadev.localhost/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=416 >=> FAIL: The damaged item is displayed in the items table >4. Restart plack: > k$ restart_all >5. Refresh the page >=> SUCCESS: The damaged item is no longer displayed >6. Undo the test data: > k$ koha-mysql kohadev <<< "UPDATE items SET damaged = 0 WHERE biblionumber = 416;" > k$ koha-mysql kohadev <<< "UPDATE systempreferences SET value = '' WHERE variable = 'OpacHiddenItems';" > k$ flush_memcached >7. Sign off :-D >--- > opac/opac-MARCdetail.pl | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index 03c2d18dd0..01ba8ff886 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -277,7 +277,8 @@ for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) { > # warning : we may have different number of columns in each row. Thus, we first build a hash, complete it if necessary > # then construct template. > # $record has already had all the item fields filtered above. >-my @fields = $record->fields(); >+$items->reset(); >+my @fields = map { $_->as_marc_field } $items->as_list; > my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code > my @item_subfield_codes; > my @item_loop; >-- >2.50.1 (Apple Git-155) >
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 40481
:
188582
|
188583
|
188584
|
188585
|
188586
|
194401
|
194446
|
194447
|
194451
|
194452