From 353f510c146cfcffc0bb488a8411755f111e5711 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 Signed-off-by: Katrin Fischer --- 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 d6308a7995..0fd56741d4 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2885,7 +2885,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 9bb9ca66bc..4464fb407a 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 { $schema->storage->txn_rollback; }; -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 cb45dd6e5c..4154994984 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.39.5