From f303b88e43f784071e42b8a62a476915257ee33a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 8 Dec 2023 17:24:35 -0300 Subject: [PATCH] Bug 34943: Implement `before_biblio_metadata_store` plugin hook This patch implements a hook allowing record modification right before they are written on the DB. The idea is that a plugin could be used to add machine-generated fields/subfields. To test: 1. Apply the unit tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t => FAIL: Tests fail! The hook is not implemented so the desired results don't appear (added fields/subfields). 3. Apply this patch 4. Repeat 2 => SUCCESS: It works! 5. Run: k$ qa -c 2 => SUCCESS: All green! 6. Sign off :-D Sponsored-by: Theke Solutions Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- C4/Biblio.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 97048ca5f35..d6308a7995e 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2885,6 +2885,8 @@ sub ModBiblioMarc { Koha::Util::MARC::set_marc_field($record, C4::Context->preference('MarcFieldForModifierName'), $borrowername); } + Koha::Plugins->call( 'before_biblio_metadata_store', $record ); + $m_rs->metadata( $record->as_xml_record($encoding) ); $m_rs->store; -- 2.44.0