mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
LdapConnection: Properly apply limit and offset for unfolded queries
refs #9772
This commit is contained in:
parent
b0559206af
commit
d720180348
@ -727,23 +727,21 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
$entries = array();
|
$entries = array();
|
||||||
$entry = ldap_first_entry($ds, $results);
|
$entry = ldap_first_entry($ds, $results);
|
||||||
|
$unfoldAttribute = $query->getUnfoldAttribute();
|
||||||
do {
|
do {
|
||||||
$count += 1;
|
if ($unfoldAttribute) {
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
$rows = $this->cleanupAttributes(
|
||||||
$row = $this->cleanupAttributes(
|
|
||||||
ldap_get_attributes($ds, $entry),
|
ldap_get_attributes($ds, $entry),
|
||||||
array_flip($fields),
|
array_flip($fields),
|
||||||
$query->getUnfoldAttribute()
|
$unfoldAttribute
|
||||||
);
|
);
|
||||||
|
|
||||||
if (is_array($row)) {
|
if (is_array($rows)) {
|
||||||
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
||||||
|
foreach ($rows as $row) {
|
||||||
$count -= 1;
|
|
||||||
foreach ($row as $additionalRow) {
|
|
||||||
$count += 1;
|
$count += 1;
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
$entries[] = $additionalRow;
|
$entries[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
||||||
@ -751,7 +749,18 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$entries[ldap_get_dn($ds, $entry)] = $row;
|
$count += 1;
|
||||||
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
|
$entries[ldap_get_dn($ds, $entry)] = $rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$count += 1;
|
||||||
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
|
$entries[ldap_get_dn($ds, $entry)] = $this->cleanupAttributes(
|
||||||
|
ldap_get_attributes($ds, $entry),
|
||||||
|
array_flip($fields)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ((! $serverSorting || $limit === 0 || $limit !== count($entries))
|
} while ((! $serverSorting || $limit === 0 || $limit !== count($entries))
|
||||||
@ -811,6 +820,7 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
$cookie = '';
|
$cookie = '';
|
||||||
$entries = array();
|
$entries = array();
|
||||||
|
$unfoldAttribute = $query->getUnfoldAttribute();
|
||||||
do {
|
do {
|
||||||
// Do not request the pagination control as a critical extension, as we want the
|
// Do not request the pagination control as a critical extension, as we want the
|
||||||
// server to return results even if the paged search request cannot be satisfied
|
// server to return results even if the paged search request cannot be satisfied
|
||||||
@ -861,22 +871,19 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
|
|
||||||
$entry = ldap_first_entry($ds, $results);
|
$entry = ldap_first_entry($ds, $results);
|
||||||
do {
|
do {
|
||||||
$count += 1;
|
if ($unfoldAttribute) {
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
$rows = $this->cleanupAttributes(
|
||||||
$row = $this->cleanupAttributes(
|
|
||||||
ldap_get_attributes($ds, $entry),
|
ldap_get_attributes($ds, $entry),
|
||||||
array_flip($fields),
|
array_flip($fields),
|
||||||
$query->getUnfoldAttribute()
|
$unfoldAttribute
|
||||||
);
|
);
|
||||||
|
|
||||||
if (is_array($row)) {
|
if (is_array($rows)) {
|
||||||
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
||||||
|
foreach ($rows as $row) {
|
||||||
$count -= 1;
|
|
||||||
foreach ($row as $additionalRow) {
|
|
||||||
$count += 1;
|
$count += 1;
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
$entries[] = $additionalRow;
|
$entries[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
||||||
@ -884,7 +891,18 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$entries[ldap_get_dn($ds, $entry)] = $row;
|
$count += 1;
|
||||||
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
|
$entries[ldap_get_dn($ds, $entry)] = $rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$count += 1;
|
||||||
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
|
$entries[ldap_get_dn($ds, $entry)] = $this->cleanupAttributes(
|
||||||
|
ldap_get_attributes($ds, $entry),
|
||||||
|
array_flip($fields)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (
|
} while (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user