[Bug 44034] New: Move parse_xml and to_xml out of Koha::REST::V1 into Koha::Util::XML
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44034 Bug ID: 44034 Summary: Move parse_xml and to_xml out of Koha::REST::V1 into Koha::Util::XML 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: --- parse_xml and to_xml convert between XML (XML::LibXML) and plain Perl data structures. They were added to Koha::REST::V1 by bug 37762 for the REST API's XML handling, but nothing about them is REST-specific. Their only callers outside Koha::REST::V1 are the ISO18626 ILL modules (Koha::ILL::ISO18626 and Koha::ILL::ISO18626::Request). Request uses them when it sends a message to a requesting agency's callback endpoint and parses the reply, so no REST controller is involved. Today those modules have to load the entire REST application to reach two helper functions, and the dependency points the wrong way: domain code depending on the API layer. Proposal: - Add Koha::Util::XML (alongside Koha::Util::MARC, Koha::Util::Normalize and friends) exporting parse_xml and to_xml, with their behaviour unchanged. - Point the ISO18626 modules at it, and have Koha::REST::V1 import them for its existing hooks. - Let parse_xml take an already-loaded definitions hashref as well as a spec file path. The path form resolves the whole spec and caches it per process, which is wasteful for callers that already hold the spec. No functional change is intended. Out of scope, noted for later: - The bundle-or-yaml spec file lookup is repeated in Koha::ILL::ISO18626::is_invalid and twice in Request.pm. Two of those feed schema validation and not parse_xml, so it needs its own home and is not an XML util concern. - to_xml takes the first key of the hash as the root element, so a hash with several keys gives an arbitrary root. This should be addressed separately, either by dying or by taking a root name. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44034 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44035 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44035 [Bug 44035] Negotiate request and response body formats in the REST API, replacing the XML/JSON hooks -- 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=44034 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211063 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211063&action=edit Bug 44034: Move parse_xml and to_xml to Koha::Util::XML They convert between XML and Perl data structures and have nothing to do with the REST app, but lived in Koha::REST::V1. Their only consumers outside of it are the ISO18626 ILL modules, which had to load the whole REST application to call them. Koha::REST::V1 imports them for its own use. No behaviour change. To test: 1. prove t/Koha/Util/XML.t t/db_dependent/Koha/REST/V1.t \ t/db_dependent/Koha/ILL/ISO18626.t \ t/db_dependent/Koha/ILL/ISO18626/Request.t \ t/db_dependent/api/v1/iso18626/ Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- 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=44034 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211064 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211064&action=edit Bug 44034: Let parse_xml take already loaded definitions parse_xml only took the path of a spec file, which it resolves (slowly, once per process) to find the array properties. Callers that already have the spec loaded, such as an OpenAPI helper, can now pass its definitions hashref instead. Passing a spec file works as before. To test: 1. prove t/Koha/Util/XML.t Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44034 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- 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=44034 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44036 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44036 [Bug 44036] Consolidate how the REST API spec file is located and loaded outside Koha::REST::V1 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44034 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44037 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44037 [Bug 44037] Koha::Util::XML::to_xml picks an arbitrary root element for hashes with several keys -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44034 David Nind <david@davidnind.com> 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=44034 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211063|0 |1 is obsolete| | Attachment #211064|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=44034 --- Comment #3 from David Nind <david@davidnind.com> --- Created attachment 211130 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211130&action=edit Bug 44034: Move parse_xml and to_xml to Koha::Util::XML They convert between XML and Perl data structures and have nothing to do with the REST app, but lived in Koha::REST::V1. Their only consumers outside of it are the ISO18626 ILL modules, which had to load the whole REST application to call them. Koha::REST::V1 imports them for its own use. No behaviour change. To test: 1. prove t/Koha/Util/XML.t t/db_dependent/Koha/REST/V1.t \ t/db_dependent/Koha/ILL/ISO18626.t \ t/db_dependent/Koha/ILL/ISO18626/Request.t \ t/db_dependent/api/v1/iso18626/ Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44034 --- Comment #4 from David Nind <david@davidnind.com> --- Created attachment 211131 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211131&action=edit Bug 44034: Let parse_xml take already loaded definitions parse_xml only took the path of a spec file, which it resolves (slowly, once per process) to find the array properties. Callers that already have the spec loaded, such as an OpenAPI helper, can now pass its definitions hashref instead. Passing a spec file works as before. To test: 1. prove t/Koha/Util/XML.t Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org