From cc0f7ec92c969916a70f4c6eb9c901ebdf761b91 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 914c323e7c..0ccea4964e 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -176,7 +176,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 20ae522231..52938ad7d1 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.30.1 (Apple Git-130)