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

--- Comment #4 from Arthur Suzuki <[email protected]> ---
Created attachment 212303
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212303&action=edit
Bug 44069: Fix svc/bib for recoverable and unrecoverable records

Koha::Biblio::Metadata->record() now repairs recoverable MARCXML faults
on read and reports them through object_messages, and
record_strip_nonxml() was removed. svc/bib still called the removed
method when metadata_record() threw Koha::Exceptions::Metadata::Invalid,
so unrecoverable records died with a missing-method error instead of
returning a proper error. Recoverable records never reached that branch,
so the invalid_metadata header was never set and the advanced cataloguing
editor no longer warned about encoding issues.

This change drops the record_strip_nonxml call and returns a 500 with an
XML error body for unrecoverable records. The invalid_metadata header is
now set from $biblio->metadata->object_messages, as
Koha::OAI::Server::Repository->get_biblio_marcxml does.

A new regression test, t/db_dependent/svc/bib.t, covers valid,
recoverable, unrecoverable and unknown records.

To test:
1. Apply the patch.
2. Create a record and store MARCXML with a control character (chr(31))
   in a subfield directly in biblio_metadata.
3. Request /cgi-bin/koha/svc/bib/<biblionumber>. Confirm the response
   carries "Invalid-metadata: 1" and the repaired record.
4. Open the record in the advanced cataloguing editor and confirm the
   "Record had encoding issues" alert is shown.
5. Store truncated XML in biblio_metadata and request the same URL.
   Confirm a 500 with an XML error body, not a missing-method error.
6. Run: prove t/db_dependent/svc/bib.t

Sponsored-by: OpenFifth
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Adolfo Rodríguez <[email protected]>
Signed-off-by: Arthur Suzuki <[email protected]>

-- 
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