Bug 15870: potential follow up to comment #8
authorMark Tompsett <mtompset@hotmail.com>
Tue, 8 Mar 2016 02:34:45 +0000 (21:34 -0500)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Thu, 24 Mar 2016 20:15:40 +0000 (20:15 +0000)
This patch:
- makes the Koha::RecordProcessor code more clear
  by removing the unnecessary newrecord variable.
- revises the filter to be more clear about the
  expectation that operations are done directly on
  the record parameter.

TEST PLAN
---------
prove t/RecordProcessor.t
prove t/db_dependent/Filter_MARC_ViewPolicy.t
run koha qa test tools

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as advertised. NO koha-qa errors
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>

Koha/Filter/MARC/ViewPolicy.pm
Koha/RecordProcessor.pm

index 14df201..98df72d 100644 (file)
@@ -78,9 +78,8 @@ sub filter {
         push @records, $precord;
     }
 
-    my @results;
     foreach my $current_record (@records) {
-        my $result        = $current_record->clone();
+        my $result        = $current_record;
         my $interface     = $self->{options}->{interface} // 'opac';
         my $frameworkcode = $self->{options}->{frameworkcode} // q{};
         my $hide          = _should_hide_on_interface();
@@ -103,15 +102,8 @@ sub filter {
                 }
             );
         }
-        push @results, $result;
-    }
-
-    if ( scalar @results == 1 ) {
-        return $results[0];
-    }
-    else {
-        return \@results;
     }
+    return;
 }
 
 sub _filter_field {
index b9d2918..1f93571 100644 (file)
@@ -152,14 +152,12 @@ sub process {
 
     return unless defined $record;
 
-    my $newrecord = $record;
-
     foreach my $filterobj (@{$self->filters}) {
         next unless $filterobj;
-        $newrecord = $filterobj->filter($newrecord);
+        $filterobj->filter($record);
     }
 
-    return $newrecord;
+    return $record;
 }
 
 sub DESTROY {