View | Details | Raw Unified | Return to bug 1707
Collapse All | Expand All

(-)a/C4/Members/Attributes.pm (-1 / +2 lines)
Lines 142-148 sub GetBorrowerAttributeValue { Link Here
142
=cut
142
=cut
143
143
144
sub SearchIdMatchingAttribute{
144
sub SearchIdMatchingAttribute{
145
    my $filter = shift;
145
    my ( $filter, $limit ) = @_;
146
    $filter = [$filter] unless ref $filter;
146
    $filter = [$filter] unless ref $filter;
147
147
148
    my $dbh   = C4::Context->dbh();
148
    my $dbh   = C4::Context->dbh();
Lines 152-157 FROM borrower_attributes Link Here
152
JOIN borrower_attribute_types USING (code)
152
JOIN borrower_attribute_types USING (code)
153
WHERE staff_searchable = 1
153
WHERE staff_searchable = 1
154
AND (} . join (" OR ", map "attribute like ?", @$filter) .qq{)};
154
AND (} . join (" OR ", map "attribute like ?", @$filter) .qq{)};
155
    $query .= q{ LIMIT ?} if $limit;
155
    my $sth = $dbh->prepare_cached($query);
156
    my $sth = $dbh->prepare_cached($query);
156
    $sth->execute(map "%$_%", @$filter);
157
    $sth->execute(map "%$_%", @$filter);
157
    return [map $_->[0], @{ $sth->fetchall_arrayref }];
158
    return [map $_->[0], @{ $sth->fetchall_arrayref }];
(-)a/C4/Utils/DataTables/Members.pm (-2 / +5 lines)
Lines 122-128 sub search { Link Here
122
        }
122
        }
123
123
124
        if ( C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
124
        if ( C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
125
            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember);
125
            # 100 is hardcoded here, it could be moved to a pref is necessary
126
            # The borrowernumbers returned by this subroutine will be concatenated to produce another SQL query
127
            # We do not want to generate a very long query as it could overload the server if the user searches
128
            # for something too generic (% for instance)
129
            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember, 100);
126
130
127
            for my $borrowernumber ( @$matching_borrowernumbers ) {
131
            for my $borrowernumber ( @$matching_borrowernumbers ) {
128
                push @where_strs_or, "borrowers.borrowernumber = ?";
132
                push @where_strs_or, "borrowers.borrowernumber = ?";
129
- 

Return to bug 1707