diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index 580a3eab49..03ef3a0d03 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -160,12 +160,8 @@ sub search { if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) { - my @matching_borrowernumbers = Koha::Patrons->filter_by_attribute_value($searchmember)->get_column('borrowernumber'); - - for my $borrowernumber ( @matching_borrowernumbers ) { - push @where_strs_or, "borrowers.borrowernumber = ?"; - push @where_args, $borrowernumber; - } + push @where_strs_or, " borrowernumber IN ( SELECT DISTINCT borrowernumber FROM borrower_attributes JOIN borrower_attribute_types USING (code) WHERE staff_searchable = 1 AND attribute LIKE ? ) "; + push @where_args, $term; } push @where_strs, '('. join (' OR ', @where_strs_or) . ')'