Bugzilla – Attachment 188401 Details for
Bug 39336
Public Biblio endpoint should honour OpacSuppression syspref
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39336: Public Biblio endpoint should honour OpacSuppression syspref
Bug-39336-Public-Biblio-endpoint-should-honour-Opa.patch (text/plain), 4.27 KB, created by
Marcel de Rooy
on 2025-10-24 07:26:29 UTC
(
hide
)
Description:
Bug 39336: Public Biblio endpoint should honour OpacSuppression syspref
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-10-24 07:26:29 UTC
Size:
4.27 KB
patch
obsolete
>From 4cb73e05c40e853510bc4210849e467ee04e760d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Thu, 9 Oct 2025 15:23:50 +0100 >Subject: [PATCH] Bug 39336: Public Biblio endpoint should honour > OpacSuppression syspref >Content-Type: text/plain; charset=utf-8 > >This patch makes the Public Biblio endpoint respect the OpacSuppression >system preference and the biblio.opac_suppressed field introduced in >Bug 38330. > >When OpacSuppression is enabled and a biblio has opac_suppressed set to 1, >the endpoint now returns a 404 (Not Found) response instead of exposing >the bibliographic record. > >Test plan: >1. Apply patch >2. Run: prove t/db_dependent/api/v1/biblios.t >3. Verify all tests pass, including the new OpacSuppression subtest >4. Test manually: > - Enable OpacSuppression syspref > - Set a biblio's opac_suppressed field to 1 > - Access /api/v1/public/biblios/{biblio_id} > - Confirm it returns 404 > - Set opac_suppressed to 0 > - Confirm it returns 200 with the record > - Disable OpacSuppression syspref > - Confirm record is visible regardless of opac_suppressed value > >Signed-off-by: David Cook <dcook@prosentient.com.au> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/REST/V1/Biblios.pm | 5 +++++ > t/db_dependent/api/v1/biblios.t | 30 +++++++++++++++++++++++++++++- > 2 files changed, 34 insertions(+), 1 deletion(-) > >diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm >index 94bca50e83..a4d50e3800 100644 >--- a/Koha/REST/V1/Biblios.pm >+++ b/Koha/REST/V1/Biblios.pm >@@ -161,6 +161,11 @@ sub get_public { > my $schema = $biblio->metadata->schema // C4::Context->preference("marcflavour"); > my $patron = $c->stash('koha.user'); > >+ # Check if the bibliographic record is suppressed in OPAC >+ if ( C4::Context->preference('OpacSuppression') && $biblio->opac_suppressed ) { >+ return $c->render_resource_not_found("Bibliographic record"); >+ } >+ > # Check if the bibliographic record should be hidden for unprivileged access > # unless there's a logged in user, and there's an exception for it's category > my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems'); >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index 9cf8db47a4..0e84d86e03 100755 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -292,7 +292,7 @@ subtest 'delete() tests' => sub { > > subtest 'get_public() tests' => sub { > >- plan tests => 25; >+ plan tests => 26; > > $schema->storage->txn_begin; > >@@ -425,6 +425,34 @@ subtest 'get_public() tests' => sub { > t::lib::Mocks::mock_preference('OpacHiddenItems'); > }; > >+ subtest 'OpacSuppression tests' => sub { >+ >+ plan tests => 8; >+ >+ # Test with OpacSuppression enabled and biblio suppressed >+ t::lib::Mocks::mock_preference( 'OpacSuppression', 1 ); >+ $biblio->set( { opac_suppressed => 1 } )->store; >+ >+ $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } ) >+ ->status_is( 404, 'OpacSuppression enabled + opac_suppressed => hidden' ); >+ >+ # Test with OpacSuppression enabled but biblio not suppressed >+ $biblio->set( { opac_suppressed => 0 } )->store; >+ $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } ) >+ ->status_is( 200, 'OpacSuppression enabled + not suppressed => displayed' ); >+ >+ # Test with OpacSuppression disabled but biblio suppressed >+ t::lib::Mocks::mock_preference( 'OpacSuppression', 0 ); >+ $biblio->set( { opac_suppressed => 1 } )->store; >+ $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } ) >+ ->status_is( 200, 'OpacSuppression disabled + opac_suppressed => displayed' ); >+ >+ # Test with both disabled >+ $biblio->set( { opac_suppressed => 0 } )->store; >+ $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } ) >+ ->status_is( 200, 'OpacSuppression disabled + not suppressed => displayed' ); >+ }; >+ > $biblio->delete; > $t->get_ok( > "//$userid:$password@/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'application/marc' } ) >-- >2.39.5
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 39336
:
187665
|
188183
| 188401