Bug 14646 - Koha::RecordProcessor only accepts one filter at a time
Summary: Koha::RecordProcessor only accepts one filter at a time
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 14645
  Show dependency treegraph
 
Reported: 2015-08-04 19:29 UTC by Tomás Cohen Arazi
Modified: 2016-12-05 21:23 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 14646: (regression test) Koha::RecordProcessor only accepts one filter at a time (2.91 KB, patch)
2015-08-05 19:17 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 14646: Koha::RecordProcessor should accept more than one filter (2.12 KB, patch)
2015-08-05 19:17 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 14646: (regression test) Koha::RecordProcessor only accepts one filter at a time (2.96 KB, patch)
2015-08-05 22:14 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14646: Koha::RecordProcessor should accept more than one filter (2.30 KB, patch)
2015-08-05 22:14 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14646: (regression test) Koha::RecordProcessor only accepts one filter at a time (3.04 KB, patch)
2015-08-19 10:48 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14646: Koha::RecordProcessor should accept more than one filter (2.38 KB, patch)
2015-08-19 10:48 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2015-08-04 19:29:37 UTC
Koha::RecordProcessor is designed and documented to accept more than one Koha::Filter as parameter. The current code only support one filter to be passed.

Regression test coming-
Comment 1 Tomás Cohen Arazi 2015-08-05 19:17:23 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi 2015-08-05 19:17:29 UTC Comment hidden (obsolete)
Comment 3 Mark Tompsett 2015-08-05 22:14:36 UTC Comment hidden (obsolete)
Comment 4 Mark Tompsett 2015-08-05 22:14:44 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2015-08-19 10:48:19 UTC
Created attachment 41655 [details] [review]
Bug 14646: (regression test) Koha::RecordProcessor only accepts one filter at a time

This patch introduces new tests to t/RecordProcessor.t so it tests for
creating processors with more than one filter. It does so by running

    my $processor = new Koha::RecordProcessor({
                            filters => ['Null','Dummy']
                        });

and testing the results.

To test:
- Apply the patch
- Run:
  $ prove t/RecordProcessor.t
=> FAIL: tests related to multiple filters fail.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2015-08-19 10:48:27 UTC
Created attachment 41656 [details] [review]
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>
Comment 7 Jonathan Druart 2015-08-19 10:49:15 UTC
(In reply to M. Tompsett from comment #4)
> NOTE: Read code. Don't like the ? operator logic, but it is
>       functional despite readability issues.

Something better to suggest?
Comment 8 Mark Tompsett 2015-08-19 13:35:35 UTC
(In reply to Jonathan Druart from comment #7)
> (In reply to M. Tompsett from comment #4)
> > NOTE: Read code. Don't like the ? operator logic, but it is
> >       functional despite readability issues.
> 
> Something better to suggest?

As noted it is merely readability issues. I do not have anything better to suggest.
Comment 9 Tomás Cohen Arazi 2015-08-20 16:48:30 UTC
Patches pushed to master.