https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43777 Bug ID: 43777 Summary: Koha::Biblio::Metadata->record should repair recoverable MARCXML faults on read Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Target Milestone: --- Bug 35104 stops MARCXML with non-XML characters or empty datafields from being saved, by repairing it in Koha::Biblio::Metadata->store() and recording what was fixed. Data that was already in the database before that (or that arrived by scripts or direct SQL outside Koha) can still be undecodable, and every place that reads it has to cope. The follow-up bugs for 35104 (43025, 43026, 43027, 43028, 43029, ...) are each re-implementing the same handling: eval { $metadata->record }, catch Koha::Exceptions::Metadata::Invalid, try repair_marcxml, fall back to record_strip_nonxml, then render the per-fault warnings in their own template. record_strip_nonxml also overlaps repair_marcxml, but only handles one of its two faults. Proposal: make the read path repair the same faults as store(). - Koha::Biblio::Metadata->record falls back to repair_marcxml when the stored MARCXML cannot be decoded, and returns the repaired MARC::Record. - The faults that were repaired are reported through object_messages, the same way store() reports them, so callers that want to tell the user can, and callers that do not care simply ignore them. record still returns a single value (no context-sensitive return). - Metadata that cannot be recovered still throws Koha::Exceptions::Metadata::Invalid. - The repair is not written back to the database; store() remains the only place that writes biblio_metadata_errors rows. - record_strip_nonxml is removed and its callers use record. - A shared template include renders the repair messages so the follow-up bugs do not each carry their own copy. Test plan: 1. Apply the patches on top of bug 35104. 2. prove t/db_dependent/Koha/Biblio/Metadata.t 3. Write MARCXML containing a control character (e.g. U+001F) or an empty datafield straight into biblio_metadata.metadata with SQL, then call $biblio->metadata->record and confirm a MARC::Record is returned and object_messages describes the repair. 4. Confirm unrecoverable MARCXML still throws Koha::Exceptions::Metadata::Invalid. 5. prove t/db_dependent/Biblio.t t/db_dependent/OAI/Server.t t/db_dependent/Exporter/Record.t Sponsored-by: OpenFifth -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.