From 5921f8aaa8dabfd733c62c1c634bed0a519f508c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 11 Mar 2024 14:33:25 -0300 Subject: [PATCH] Bug 34943: (QA follow-up) Use `before_biblio_action` and an `action` param This patch harmonizes the hook name and parameters with the rest of the codebase. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ qa => SUCCESS: All looks green, and tests still pass (i.e. they were correctly adjusted to the new schema). 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- C4/Biblio.pm | 5 ++++- .../Koha/Plugins/Biblio_and_Items_plugin_hooks.t | 2 +- t/lib/plugins/Koha/Plugin/Test.pm | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 8bf80643743..51e0b5daa8a 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2889,7 +2889,10 @@ sub ModBiblioMarc { Koha::Util::MARC::set_marc_field($record, C4::Context->preference('MarcFieldForModifierName'), $borrowername); } - Koha::Plugins->call( 'before_biblio_metadata_store', $record ); + Koha::Plugins->call( + 'before_biblio_action', + { action => 'save', payload => { biblio_id => $biblionumber, record => $record } } + ); $m_rs->metadata( $record->as_xml_record($encoding) ); $m_rs->store; diff --git a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t index cd4d61c530c..8f34ec0bdc3 100755 --- a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t +++ b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t @@ -88,7 +88,7 @@ subtest 'after_biblio_action() and after_item_action() hooks tests' => sub { Koha::Plugins::Methods->delete; }; -subtest 'before_biblio_metadata_store() hooks tests' => sub { +subtest 'before_biblio_action() hooks tests' => sub { plan tests => 5; diff --git a/t/lib/plugins/Koha/Plugin/Test.pm b/t/lib/plugins/Koha/Plugin/Test.pm index cb45dd6e5c5..4154994984d 100644 --- a/t/lib/plugins/Koha/Plugin/Test.pm +++ b/t/lib/plugins/Koha/Plugin/Test.pm @@ -149,8 +149,13 @@ sub after_hold_create { Koha::Exception->throw("after_hold_create called with parameter " . ref($param) ); } -sub before_biblio_metadata_store { - my ( $self, $record ) = @_; +sub before_biblio_action { + my ( $self, $params ) = @_; + + my $action = $params->{action} // ''; + my $payload = $params->{payload}; + my $bibli_id = $payload->{biblio_id}; + my $record = $payload->{record}; $record->insert_fields_ordered( MARC::Field->new( -- 2.44.0