From 836e950d25148ca04ed0561c487772e3b0f7f8ee Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 16 Jul 2018 14:23:27 -0300 Subject: [PATCH] Bug 20443: Remove SearchIdMatchingAttribute Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- C4/Members.pm | 1 - C4/Members/Attributes.pm | 15 +-------------- C4/Utils/DataTables/Members.pm | 5 ++--- t/db_dependent/Members/Attributes.t | 8 -------- 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 9355436c33..6c10eeeb2c 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -33,7 +33,6 @@ use C4::Reserves; use C4::Accounts; use C4::Biblio; use C4::Letters; -use C4::Members::Attributes qw(SearchIdMatchingAttribute); use C4::NewsChannels; #get slip news use DateTime; use Koha::Database; diff --git a/C4/Members/Attributes.pm b/C4/Members/Attributes.pm index 19b5b9e6ef..76cd6a9b32 100644 --- a/C4/Members/Attributes.pm +++ b/C4/Members/Attributes.pm @@ -32,7 +32,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT_OK = qw( extended_attributes_code_value_arrayref extended_attributes_merge - SearchIdMatchingAttribute); + ); %EXPORT_TAGS = ( all => \@EXPORT_OK ); } @@ -46,19 +46,6 @@ C4::Members::Attributes - manage extend patron attributes =head1 FUNCTIONS -=head2 SearchIdMatchingAttribute - - my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($filter); - -=cut -use Koha::Patrons; -sub SearchIdMatchingAttribute{ - my $filter = shift; - - my @borrowernumbers = Koha::Patrons->filter_by_attribute_value($filter)->get_column('borrowernumber'); - return \@borrowernumbers; -} - =head2 extended_attributes_code_value_arrayref my $patron_attributes = "homeroom:1150605,grade:01,extradata:foobar"; diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index c4726ec89f..b7887a858e 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -4,7 +4,6 @@ use Modern::Perl; use C4::Context; use C4::Utils::DataTables; use Koha::DateUtils; -use C4::Members::Attributes qw(SearchIdMatchingAttribute ); sub search { my ( $params ) = @_; @@ -131,9 +130,9 @@ sub search { if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) { - my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember); + my @matching_borrowernumbers = Koha::Patrons->filter_by_attribute_value($searchmember)->get_column('borrowernumber'); - for my $borrowernumber ( @$matching_borrowernumbers ) { + for my $borrowernumber ( @matching_borrowernumbers ) { push @where_strs_or, "borrowers.borrowernumber = ?"; push @where_args, $borrowernumber; } diff --git a/t/db_dependent/Members/Attributes.t b/t/db_dependent/Members/Attributes.t index 32e9c7e365..33aa063d95 100644 --- a/t/db_dependent/Members/Attributes.t +++ b/t/db_dependent/Members/Attributes.t @@ -182,14 +182,6 @@ throws_ok { # Creating a new one, but already exists! } 'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint'; -my $borrower_numbers = C4::Members::Attributes::SearchIdMatchingAttribute('attribute1'); -is( @$borrower_numbers, 0, 'SearchIdMatchingAttribute searchs only in attributes with staff_searchable=1' ); -for my $attr( split(' ', $attributes->[1]->{attribute}) ) { - $borrower_numbers = C4::Members::Attributes::SearchIdMatchingAttribute($attr); - is( $borrower_numbers->[0], $borrowernumber, 'SearchIdMatchingAttribute returns the borrower numbers matching' ); -} - - $patron->get_extended_attribute($attribute->{code})->delete; $borrower_attributes = $patron->extended_attributes; is( $borrower_attributes->count, 2, 'delete attribute by code' ); -- 2.39.5