From 7b7a7c9299eca3f6615158b6a5f73e125ba562a8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 4 May 2015 11:36:38 +0200 Subject: [PATCH] Ldap\Connection: Add proper order support Will now utilize SimpleQuery::compare() to provide support for multiple order columns. refs #8826 refs #7693 --- library/Icinga/Protocol/Ldap/Connection.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 0472d5079..edda85dcf 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -304,10 +304,6 @@ class Connection implements Selectable return array(); } - foreach ($query->getSortColumns() as $col) { - ldap_sort($this->ds, $results, $col[0]); - } - $count = 0; $entries = array(); $entry = ldap_first_entry($this->ds, $results); @@ -320,6 +316,10 @@ class Connection implements Selectable } } while (($limit === 0 || $limit !== count($entries)) && ($entry = ldap_next_entry($this->ds, $entry))); + if ($query->hasOrder()) { + uasort($entries, array($query, 'compare')); + } + ldap_free_result($results); return $entries; } @@ -444,7 +444,11 @@ class Connection implements Selectable ldap_control_paged_result($this->ds, 0); } - return $entries; // TODO(7693): Sort entries post-processed + if ($query->hasOrder()) { + uasort($entries, array($query, 'compare')); + } + + return $entries; } protected function cleanupAttributes($attributes, array $requestedFields)