From c7465028c887dd08bd4f1ca044f25db5703462b9 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Mon, 7 Mar 2016 21:34:45 -0500 Subject: [PATCH] Bug 15870 - potential follow up to comment #8 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 --- Koha/Filter/MARC/ViewPolicy.pm | 12 ++---------- Koha/RecordProcessor.pm | 6 ++---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/Koha/Filter/MARC/ViewPolicy.pm b/Koha/Filter/MARC/ViewPolicy.pm index 14df201..98df72d 100644 --- a/Koha/Filter/MARC/ViewPolicy.pm +++ b/Koha/Filter/MARC/ViewPolicy.pm @@ -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 { diff --git a/Koha/RecordProcessor.pm b/Koha/RecordProcessor.pm index b9d2918..1f93571 100644 --- a/Koha/RecordProcessor.pm +++ b/Koha/RecordProcessor.pm @@ -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 { -- 2.1.4