[Bug 44074] New: Koha::Item columns_to_str and additional_attributes do not guard undecodable more_subfields_xml
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 Bug ID: 44074 Summary: Koha::Item columns_to_str and additional_attributes do not guard undecodable more_subfields_xml Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl Target Milestone: --- Follow-up to bug 43024. Bug 43024 guards the paths it names against undecodable MARC. The same class of problem exists in Koha/Item.pm, which decodes the items.more_subfields_xml column with no error handling: - columns_to_str: MARC::Record->new_from_xml( $self->more_subfields_xml, 'UTF-8' ) is called without an eval, so one item with corrupt more_subfields_xml makes the whole call die. - additional_attributes: Koha::Item::Attributes->new_from_marcxml( $self->more_subfields_xml ) should be checked for the same weakness. Fix: guard these calls the same way bug 43024 guards C4::Items::_parse_unlinked_item_subfields_from_xml (catch the error, log it with the itemnumber through Koha::Logger, and carry on without the unlinked subfields). Test plan: 1. Apply the patch (and bug 43024). 2. Corrupt an item's more_subfields_xml directly in the database. 3. View the record or call the code paths that use columns_to_str and additional_attributes for that item. 4. Confirm the page or call still works, the item is shown without its unlinked subfields, and the problem is logged. 5. prove t/db_dependent/Koha/Item.t Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk Depends on| |43024 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43024 [Bug 43024] A couple of lower-traffic paths don't guard against undecodable MARC either -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211534 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211534&action=edit Bug 44074: Guard undecodable more_subfields_xml in Koha::Item Bug 43024 guards C4::Items::_parse_unlinked_item_subfields_from_xml against undecodable items.more_subfields_xml. The same column is decoded without error handling in two more places: - Koha::Item->columns_to_str called MARC::Record->new_from_xml with no eval, so one item with corrupt more_subfields_xml made the whole call die. - Koha::Item::Attributes->new_from_marcxml (used by Koha::Item->additional_attributes) also died on undecodable XML, and additionally died on well-formed XML that has no 999 field. Catch the error, log it with Koha::Logger (with the itemnumber where it is known) and carry on without the unlinked subfields. To test: 1. Apply the patch (and bug 43024) and restart_all 2. prove t/db_dependent/Koha/Item.t t/db_dependent/Koha/Item/Attributes.t => SUCCESS: Tests pass 3. Corrupt an item's more_subfields_xml directly in the database (for example truncate it) and view the record's items => The page still works, the item is shown without its unlinked subfields and a warning is logged Sponsored-by: OpenFifth Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211534|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 --- Comment #2 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 211633 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211633&action=edit Bug 44074: Guard undecodable more_subfields_xml in Koha::Item Bug 43024 guards C4::Items::_parse_unlinked_item_subfields_from_xml against undecodable items.more_subfields_xml. The same column is decoded without error handling in two more places: - Koha::Item->columns_to_str called MARC::Record->new_from_xml with no eval, so one item with corrupt more_subfields_xml made the whole call die. - Koha::Item::Attributes->new_from_marcxml (used by Koha::Item->additional_attributes) also died on undecodable XML, and additionally died on well-formed XML that has no 999 field. Catch the error, log it with Koha::Logger (with the itemnumber where it is known) and carry on without the unlinked subfields. To test: 1. Apply the patch (and bug 43024) and restart_all 2. prove t/db_dependent/Koha/Item.t t/db_dependent/Koha/Item/Attributes.t => SUCCESS: Tests pass 3. Corrupt an item's more_subfields_xml directly in the database (for example truncate it) and view the record's items => The page still works, the item is shown without its unlinked subfields and a warning is logged Sponsored-by: OpenFifth Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |adolfo.rodriguez@xercode.es --- Comment #3 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Tested on main with an item whose more_subfields_xml was truncated (<record><leader>truncated), applied on top of bug 43024. Before the patch, the following pages died with a 500 and the XML parser error: Add/edit item (cataloguing/additem.pl) MARCXML export from the staff interface (catalogue/export.pl, items embedded) Batch item modification (tools/batchMod.pl) After the patch, all three pages load, the item is shown or exported without its unlinked subfields, and a warning naming the itemnumber is logged. QA tools pass, and t/db_dependent/Koha/Item.t and t/db_dependent/Koha/Item/Attributes.t pass. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44074 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |lucas@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org