From 062ef2064c57e15bf9ab93ad897b46b50d0f579d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 23 Mar 2021 16:08:12 +0000 Subject: [PATCH] Bug 26351: Use call_recursive() as a replacement for call() The method `call()` is not sufficient for barcode transformations. It's possible that more than one barcode transformation plugin will be installed. The `call_recursive()` method takes the output of the first plugin and uses it as the input for the next plugin and so on. This allowes each plugin to see the current version of the barcode and modify it if necessary. Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 2 +- t/db_dependent/Koha/Plugins/Plugins.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c3277e43ca3..f2e3a7c1664 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -166,7 +166,7 @@ sub barcodedecode { my ($barcode, $filter) = @_; my $branch = C4::Context::mybranch(); $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter; - ($barcode) = Koha::Plugins->call('item_barcode_transform', $barcode ) || $barcode; + ($barcode) = Koha::Plugins->call_recursive('item_barcode_transform', $barcode ); $filter or return $barcode; # ensure filter is defined, else return untouched barcode if ($filter eq 'whitespace') { $barcode =~ s/\s//g; diff --git a/t/db_dependent/Koha/Plugins/Plugins.t b/t/db_dependent/Koha/Plugins/Plugins.t index 5a1752cd611..f093a0a8e87 100755 --- a/t/db_dependent/Koha/Plugins/Plugins.t +++ b/t/db_dependent/Koha/Plugins/Plugins.t @@ -126,7 +126,7 @@ subtest 'GetPlugins() tests' => sub { @plugins = $plugins->GetPlugins({ metadata => { my_example_tag => 'find_me' }, all => 1 }); @names = map { $_->get_metadata()->{'name'} } @plugins; - is( scalar @names, 2, "Only two plugins found via a metadata tag" ); + is( scalar @names, 4, "Only four plugins found via a metadata tag" ); $schema->storage->txn_rollback; }; -- 2.25.1