Bugzilla – Attachment 41656 Details for
Bug 14646
Koha::RecordProcessor only accepts one filter at a time
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14646: Koha::RecordProcessor should accept more than one filter
Bug-14646-KohaRecordProcessor-should-accept-more-t.patch (text/plain), 2.38 KB, created by
Jonathan Druart
on 2015-08-19 10:48:27 UTC
(
hide
)
Description:
Bug 14646: Koha::RecordProcessor should accept more than one filter
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-08-19 10:48:27 UTC
Size:
2.38 KB
patch
obsolete
>From be859afc7776829cdf7b0439e5198c0819a7070b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 5 Aug 2015 16:10:19 -0300 >Subject: [PATCH] Bug 14646: Koha::RecordProcessor should accept more than one > filter > >The docs say that Koha::RecordProcessor accepts more than one filter >at a time. But as the regression tests show it doesn't. > >This is really important to extend its usage in record processing >(either to enforce policy, transform, etc). > >This patch makes ->new evaluate the reference type of the passed filters >and builds an array with a single item if a scalar has been passed. The >loop now explicitly casts the filters as an array. > >To test: >- Apply the test patch >- Run > $ prove t/RecordProcessor.t >=> FAIL: tests fail because Koha::RecordProcessor doesn't hanlde > more than one filter at a time. >- Apply this patch >- Run > $ prove t/RecordProcessor.t >=> SUCCESS: tests now pass >- Easy, right? Sign off :-D > >NOTE: Read code. Don't like the ? operator logic, but it is > functional despite readability issues. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/RecordProcessor.pm | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > >diff --git a/Koha/RecordProcessor.pm b/Koha/RecordProcessor.pm >index 9bb1fc2..cbbd726 100644 >--- a/Koha/RecordProcessor.pm >+++ b/Koha/RecordProcessor.pm >@@ -57,8 +57,8 @@ clone it I<prior> to passing it off to the RecordProcessor. > > =cut > >-use strict; >-use warnings; >+use Modern::Perl; >+ > use Module::Load::Conditional qw(can_load); > use Module::Pluggable::Object; > >@@ -90,15 +90,20 @@ Koha::Filter::${schema} namespace, as only the filter name, and > > =cut > sub new { >+ > my $class = shift; > my $param = shift; > > >- my $schema = $param->{schema} || 'MARC'; >+ my $schema = $param->{schema} || 'MARC'; > my $options = $param->{options} || ''; >+ >+ my $req_filters = ( ref($param->{filters}) ne 'ARRAY' ) >+ ? [ $param->{filters} ] >+ : $param->{filters}; > my @filters = ( ); > >- foreach my $filter ($param->{filters}) { >+ foreach my $filter (@{ $req_filters }) { > next unless $filter; > my $filter_module = $filter =~ m/:/ ? $filter : "Koha::Filter::${schema}::${filter}"; > if (can_load( modules => { $filter_module => undef } )) { >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14646
:
41388
|
41389
|
41391
|
41392
|
41655
| 41656