https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40850
Martin Renvoize (ashimema) <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #186734|0 |1 is obsolete| | --- Comment #4 from Martin Renvoize (ashimema) <[email protected]> --- Created attachment 186755 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=186755&action=edit Bug 40850: Add `Koha::ILL::Request->add_or_update_attributes` Currently, ILL backends and plugins must implement custom logic to update existing extended attributes on ILL requests, as the core extended_attributes() method only supports adding new attributes and throws duplicate key errors when attempting to update existing ones. This has led to code duplication across multiple ILL plugins (Rapido, INNReach, SLNP) that all implement identical add_or_update_attributes() methods, and forces the Standard backend to use error-prone patterns when managing request metadata. This patch adds add_or_update_attributes() method to Koha::ILL::Request that provides a safe, efficient way to add new attributes or update existing ones in a single operation, eliminating duplicate key errors and reducing code duplication. The method: - Accepts a hashref of attribute type => value pairs - Updates existing attributes only when values actually change - Creates new attributes when they don't exist - Skips undefined or empty values to avoid constraint errors - Uses transactions for atomicity - Returns the request object for method chaining Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/ILL/Request.t => SUCCESS: Tests pass! New method works correctly 3. Test adding new attributes works 4. Test updating existing attributes works 5. Test mixed add/update operations work 6. Test empty/undefined values are skipped 7. Sign off :-D Signed-off-by: Martin Renvoize <[email protected]> -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
