Koha-clms/Koha/REST/V1
Olivia Reynolds 4dd0bfc107
Bug 39337: Add is_opac_suppressed helper to C4::Context
Previously, OPAC suppression was applied inconsistently, with only some
callers taking OpacSuppressionByIPRange into account. This patch adds a
new helper to C4::Context to determine whether OPAC suppression should
be active for this request, and switches to using it everywhere that was
previously manually checking the system preferences.

Test plan (specific URLs given for KTD, with thanks to David Cook):

1.  Apply patch.
2.  Navigate to http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=2
3.  Set 942$n to "Yes" and save the record.
4.  Disable the system preference "OpacSuppression", and ensure
    "OpacSuppressionByIPRange" is blank.

5a. Verify you can successfully access
    http://localhost:8080/cgi-bin/koha/opac-detail.pl?biblionumber=2
5b. Verify you can successfully access
    http://localhost:8080/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=2
5c. Verify you can successfully access
    http://localhost:8080/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=2
5d. Verify you can successfully access
    http://localhost:8080/cgi-bin/koha/opac-search.pl?idx=&q=The+ideas+behind&weight_search=1
5e. Verify you can successfully access
    http://localhost:8080/api/v1/public/biblios/2
5f. Verify you can successfully access
    http://localhost:8080/cgi-bin/koha/oai.pl?verb=GetRecord&metadataPrefix=oai_dc&identifier=KOHA-OAI-TEST:2
5g. Verify KOHA-OAI-TEST-2 appears on
    http://localhost:8080/cgi-bin/koha/oai.pl?verb=ListRecords&metadataPrefix=oai_dc

6.  Enable the system preference "OpacSuppression", and ensure
    "OpacSuppressionByIPRange" is blank.
7.  Repeat steps 5a-5g, verifying that:
    - the OPAC details pages return "Record blocked".
    - the OPAC search page returns "No results found".
    - the API returns "Bibliographic record not found".
    - the OAI GetRecord and ListRecords show "Record Status: deleted"
      for KOHA-OAI-TEST-2.
8.  Keep "OpacSuppression" enabled, but set "OpacSuppressionByIPRange"
    to "." (to allow all IPs to bypass suppression).
9.  Repeat steps 5a-5g, verifying that every page is successful again.
10. Run `prove t/Context.t`, and verify all tests are successful.

Sponsored-by: Open Fifth
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-08-25 08:56:25 +00:00
..
Acquisitions Bug 29668: Adapt to current guidelines 2026-01-21 15:28:16 -07:00
Auth
…
Biblios
…
CashRegisters Bug 40445: Add configuration options and UI enhancements 2026-07-27 12:12:36 +00:00
Clubs
…
Config Bug 22639: Add GET /config/search_mappings endpoint 2026-04-15 11:37:17 -06:00
ERM Bug 42130: ERM - Index biblio when local title is created/updated 2026-06-05 14:25:54 +00:00
ILL Bug 37762: (QA follow-up): Warn and return 500 on schema validation failure in progress_request 2026-05-15 08:11:12 -06:00
OAuth Bug 40736: (QA follow-up) Avoid redundant CGISESSID cookie lookups 2026-08-14 12:09:23 +00:00
Patrons Bug 35797: (QA follow-up) Use https in API comment 2026-08-14 12:09:26 +00:00
Preservation
…
SIP2 Bug 37893: Fix http links 2025-11-18 11:21:20 -07:00
StockRotation
…
ActionLogs.pm Bug 29016: (QA follow-up) Document the action_logs list controller 2026-05-05 13:42:11 -06:00
AdditionalContents.pm
…
AdvancedEditorMacro.pm
…
ArticleRequests.pm
…
Auth.pm
…
AuthorisedValueCategories.pm
…
AuthorisedValues.pm
…
Authorities.pm Bug 41901: Allow duplicate check when adding authority via API 2026-04-29 09:09:12 -06:00
BackgroundJobs.pm
…
Biblios.pm Bug 39337: Add is_opac_suppressed helper to C4::Context 2026-08-25 08:56:25 +00:00
Bookings.pm Bug 41898: Introduce 'issued' status and update booking display/filtering 2026-07-27 15:53:33 +00:00
CSPReports.pm Bug 38365: Make swagger-cli happy 2026-03-16 11:57:37 +01:00
Checkouts.pm Bug 23909: Apply hold policy to OPAC REST self-checkout 2026-05-01 11:04:20 -06:00
CirculationRules.pm
…
Cities.pm
…
DeletedBiblios.pm Bug 17387: (follow-up) fix embed items on get deleted biblio 2026-04-15 14:10:28 -06:00
DeletedItems.pm Bug 17387: (follow-up) address review feedback 2026-04-15 14:10:27 -06:00
ERM.pm Bug 39320: Preparation: ERM counts API endpoint 2026-01-13 15:03:20 -07:00
ExtendedAttributeTypes.pm Bug 39438: (bug 38446 follow-up) Add agreement_period to /erm/extended_attribute_types 2026-01-30 10:54:11 -07:00
Holds.pm Bug 41801: (QA follow-up) Ensure toggling priority sets correct rank 2026-03-21 20:28:16 +00:00
ILL.pm Bug 42845: Add ILL config endpoint for Vue app 2026-07-27 15:53:48 +00:00
ImportBatchProfiles.pm
…
ImportRecordMatches.pm
…
ItemTypes.pm
…
Items.pm Bug 40154: prevent deletion of items with holds 2026-02-10 10:52:04 -07:00
Libraries.pm Bug 42206: (follow-up) Rename to /closed_dates, improve efficiency 2026-05-01 11:04:25 -06:00
Lists.pm
…
OAuth.pm
…
Patrons.pm Bug 41733: Honor EmailPatronRegistrations in the API 2026-04-15 11:37:13 -06:00
Preservation.pm
…
Quotes.pm
…
RecordSources.pm Bug 35380: Change record sources to by systemdefined 2026-03-26 09:46:15 +01:00
ReturnClaims.pm
…
SearchFilter.pm
…
Static.pm
…
Status.pm Bug 41107: Add /status/version API endpoint 2026-03-23 09:33:54 +01:00
Suggestions.pm Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
Sysprefs.pm Bug 41994: Implement /sysprefs route to list system preferences 2026-04-15 11:37:05 -06:00
Tickets.pm
…
TransferLimits.pm
…
TwoFactorAuth.pm
…