From a4fec6f42e14aab2bb6038ec70d711cb2dd6ceac Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 8 Sep 2015 14:29:31 +0200 Subject: [PATCH] lib: Fix LdapConnection::encodeSortRules() - Fix reverseOrder encoding - Support PHP < 5.4 --- library/Icinga/Protocol/Ldap/LdapConnection.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/LdapConnection.php b/library/Icinga/Protocol/Ldap/LdapConnection.php index d78b4a147..ed93ecf7e 100644 --- a/library/Icinga/Protocol/Ldap/LdapConnection.php +++ b/library/Icinga/Protocol/Ldap/LdapConnection.php @@ -939,8 +939,8 @@ class LdapConnection implements Selectable, Inspectable $sequenceOf = ''; foreach ($sortRules as $rule) { - if (false && $rule[1] === Sortable::SORT_DESC) { - $reversed = '0101ff'; + if ($rule[1] === Sortable::SORT_DESC) { + $reversed = '8101ff'; } else { $reversed = ''; } @@ -974,7 +974,11 @@ class LdapConnection implements Selectable, Inspectable $sequenceOf = '30' . str_pad(dechex($sequenceOfOctets), 2, '0', STR_PAD_LEFT) . $sequenceOf; } - return hex2bin($sequenceOf); + if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + return hex2bin($sequenceOf); + } else { + return pack('H*', $sequenceOf); + } } /**