Bug 14646

Summary: Koha::RecordProcessor only accepts one filter at a time
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: jcamins, jonathan.druart, mtompset, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 14645    
Attachments: Bug 14646: (regression test) Koha::RecordProcessor only accepts one filter at a time
Bug 14646: Koha::RecordProcessor should accept more than one filter
Bug 14646: (regression test) Koha::RecordProcessor only accepts one filter at a time
Bug 14646: Koha::RecordProcessor should accept more than one filter
Bug 14646: (regression test) Koha::RecordProcessor only accepts one filter at a time
Bug 14646: Koha::RecordProcessor should accept more than one filter

Description Tomás Cohen Arazi (tcohen) 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 (tcohen) 2015-08-05 19:17:23 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi (tcohen) 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 (tcohen) 2015-08-20 16:48:30 UTC
Patches pushed to master.