From 3b6238af139b8bae8f90769ca1db02bf35c0e401 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 25 Feb 2022 05:54:11 -0300 Subject: [PATCH] Bug 30180: (follow-up) Add temporary deprecation warning This patch adds a temporary deprecation warning to let users know the plugin needs to get updated before the next release. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Holds_hooks.t => SUCCESS: Tests pass, warning is displayed 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers --- Koha/Plugins.pm | 3 +++ t/db_dependent/Koha/Plugins/Holds_hooks.t | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 033ba28376..f7b716638d 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -78,6 +78,9 @@ sub call { if (C4::Context->config('enable_plugins')) { my @plugins = $class->new({ enable_plugins => 1 })->GetPlugins({ method => $method }); @plugins = grep { $_->can($method) } @plugins; + # TODO: Remove warn when after_hold_create is removed from the codebase + warn "after_hold_create is deprecated and will be removed soon. Contact the following plugin's authors: " . join( ', ', map {$_->{metadata}->{name}} @plugins) + if $method eq 'after_hold_create' and @plugins; foreach my $plugin (@plugins) { my $response = eval { $plugin->$method(@args) }; if ($@) { diff --git a/t/db_dependent/Koha/Plugins/Holds_hooks.t b/t/db_dependent/Koha/Plugins/Holds_hooks.t index 83bf3fed0c..c259aeb1bc 100755 --- a/t/db_dependent/Koha/Plugins/Holds_hooks.t +++ b/t/db_dependent/Koha/Plugins/Holds_hooks.t @@ -72,12 +72,13 @@ subtest 'after_hold_create() hook tests' => sub { my $biblio = $builder->build_sample_biblio(); my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); - warning_like { AddReserve({ + warnings_like { AddReserve({ branchcode => $patron->branchcode, borrowernumber => $patron->borrowernumber, biblionumber => $item_1->biblionumber }); } - qr/after_hold_create called with parameter Koha::Hold/, - 'AddReserve calls the after_hold_create hook'; + [ qr/after_hold_create is deprecated and will be removed soon/, + qr/after_hold_create called with parameter Koha::Hold/ ], + 'AddReserve calls the after_hold_create hook, deprecation warning found'; $schema->storage->txn_rollback; Koha::Plugins::Methods->delete; @@ -113,7 +114,7 @@ subtest 'after_hold_action (placed) hook tests' => sub { my $biblio = $builder->build_sample_biblio(); my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); - warning_like { + warnings_like { AddReserve( { branchcode => $patron->branchcode, borrowernumber => $patron->borrowernumber, @@ -121,7 +122,7 @@ subtest 'after_hold_action (placed) hook tests' => sub { } ); } - qr/after_hold_action called with action: place, ref: Koha::Hold/, 'AddReserve calls the after_hold_action hook'; + [ qr/after_hold_create is deprecated and will be removed soon/, qr/after_hold_action called with action: place, ref: Koha::Hold/, ], 'AddReserve calls the after_hold_action hook'; $schema->storage->txn_rollback; Koha::Plugins::Methods->delete; -- 2.39.5