LdapConnection: Respect a query's offset not only for ordered results

refs #2765
This commit is contained in:
Johannes Meyer 2018-01-16 12:55:20 +01:00
parent 37f22518bb
commit ce4ae47805
1 changed files with 10 additions and 4 deletions

View File

@ -823,8 +823,11 @@ class LdapConnection implements Selectable, Inspectable
&& ($entry = ldap_next_entry($ds, $entry))
);
if (! $serverSorting && $query->hasOrder()) {
uasort($entries, array($query, 'compare'));
if (! $serverSorting) {
if ($query->hasOrder()) {
uasort($entries, array($query, 'compare'));
}
if ($limit && $count > $limit) {
$entries = array_splice($entries, $query->hasOffset() ? $query->getOffset() : 0, $limit);
}
@ -994,8 +997,11 @@ class LdapConnection implements Selectable, Inspectable
ldap_search($ds, $query->getBase() ?: $this->getDn(), (string) $query);
}
if (! $serverSorting && $query->hasOrder()) {
uasort($entries, array($query, 'compare'));
if (! $serverSorting) {
if ($query->hasOrder()) {
uasort($entries, array($query, 'compare'));
}
if ($limit && $count > $limit) {
$entries = array_splice($entries, $query->hasOffset() ? $query->getOffset() : 0, $limit);
}