https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43606

--- Comment #15 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 211108
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211108&action=edit
Bug 43606: (QA follow-up) Do not hide fields when embedding items

When 'x-koha-embed: items' is sent to GET /biblios, the list controller
passes interface => 'intranet' to print_collection, which forwards it to
Koha::Biblio->metadata_record. Besides scoping the items, any interface
makes metadata_record apply the ViewPolicy filter, so the fields the
framework hides in the staff interface (e.g. 955 in the sample data)
disappear from the record, only when items are requested.

This patch addresses comment #13 by not passing an interface from the
staff list endpoint. metadata_record then only embeds the items (all of
them, as for the intranet interface), and the rest of the record is
returned as stored, like without the header and like
GET /biblios/{biblio_id} does.

The POD of print_collection now mentions that passing an interface also
applies the ViewPolicy filter.

Test plan:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/biblios.t
=> FAIL: The field hidden in the staff interface is missing when items
   are embedded
2. Apply this patch
3. Run:
  k$ restart_all
  k$ prove t/db_dependent/api/v1/biblios.t \
           t/db_dependent/Koha/Objects/Record/Collections.t
=> SUCCESS: Tests pass!
4. Count the 952 and 955 fields of biblio 1, without and with the embed:
  k$ curl -s -u koha:koha -H "Accept: application/marcxml+xml" \
       "http://localhost:8081/api/v1/biblios?q=%7B%22biblio_id%22%3A1%7D"; \
       | grep -oE 'tag="95[25]"' | sort | uniq -c
=> SUCCESS: 1 tag="955"
  k$ curl -s -u koha:koha -H "Accept: application/marcxml+xml" \
       -H "x-koha-embed: items" \
       "http://localhost:8081/api/v1/biblios?q=%7B%22biblio_id%22%3A1%7D"; \
       | grep -oE 'tag="95[25]"' | sort | uniq -c
=> SUCCESS: 1 tag="952" and 1 tag="955"
5. Sign off :-D

Assisted-by: Opus 5.5 (Anthropic)

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to