From: Dobrica Pavlinusic Date: Wed, 29 Apr 2009 09:29:46 +0000 (+0000) Subject: use limit just for object classes which have "person" in them X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=commitdiff_plain;h=944ac5011bf7f15d11f6768e2aafa4545b2d974f;ds=sidebyside use limit just for object classes which have "person" in them use MAX_RESULTS enviroment variable if it exists (default: 3000 entries) This is done to support full list of organizationalUnit and group members which is often more than MAX_RESULTS limit --- diff --git a/lib/LDAP/Koha.pm b/lib/LDAP/Koha.pm index 0eacc09..7c2791c 100644 --- a/lib/LDAP/Koha.pm +++ b/lib/LDAP/Koha.pm @@ -25,7 +25,7 @@ our $database = 'koha'; our $user = 'unconfigured-user'; our $passwd = 'unconfigured-password'; -our $max_results = 3000; # FIXME must be enough for all users +our $max_results = $ENV{MAX_RESULTS} || 3000; # FIXME must be enough for all users our $objectclass_default = 'hrEduPerson'; our $objectclass; @@ -199,8 +199,14 @@ sub search { } - warn "# SQL:\n$sql_select\n", $sql_where ? $sql_where : '-- no where', "\n# DATA: ",dump( @values ); - my $sth = $dbh->prepare( $sql_select . $sql_where . " LIMIT $max_results" ); # XXX remove limit? + my $sql + = $sql_select + . $sql_where + . ( $objectclass =~ m{person}i ? " LIMIT $max_results" : '' ) # add limit just for persons + ; + + warn "# SQL:\n$sql\n# DATA: ",dump( @values ); + my $sth = $dbh->prepare( $sql ); $sth->execute( @values ); warn "# ", $sth->rows, " results for ",dump( $reqData->{'filter'} );