Skip to content

Commit

Permalink
fix(ldapselect): drop support for PHP 7.3 as GLPI supports 7.4 and later
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Nov 26, 2021
1 parent c477ae9 commit 7033c3a
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions inc/field/ldapselectfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,25 +270,19 @@ public function prepareQuestionInputForSave($input) {
$cookie = '';
$ds = $config_ldap->connect();
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if (version_compare(PHP_VERSION, '7.3') < 0) {
// phpcs:ignore Generic.PHP.DeprecatedFunctions
ldap_control_paged_result($ds, 1, false, $cookie);
$result = ldap_search($ds, $config_ldap->fields['basedn'], $input['ldap_filter'], $attribute);
} else {
$controls = [
[
'oid' =>LDAP_CONTROL_PAGEDRESULTS,
'iscritical' => false,
'value' => [
'size' => $config_ldap->fields['pagesize'],
'cookie' => $cookie
]
$controls = [
[
'oid' =>LDAP_CONTROL_PAGEDRESULTS,
'iscritical' => false,
'value' => [
'size' => $config_ldap->fields['pagesize'],
'cookie' => $cookie
]
];
$result = ldap_search($ds, $config_ldap->fields['basedn'], $input['ldap_filter'], $attribute, 0, -1, -1, LDAP_DEREF_NEVER, $controls);
ldap_parse_result($ds, $result, $errcode, $matcheddn, $errmsg, $referrals, $controls);
$cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? '';
}
]
];
$result = ldap_search($ds, $config_ldap->fields['basedn'], $input['ldap_filter'], $attribute, 0, -1, -1, LDAP_DEREF_NEVER, $controls);
ldap_parse_result($ds, $result, $errcode, $matcheddn, $errmsg, $referrals, $controls);
$cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? '';
ldap_get_entries($ds, $result);
} catch (Exception $e) {
Session::addMessageAfterRedirect(__('Cannot recover LDAP informations!', 'formcreator'), false, ERROR);
Expand Down

0 comments on commit 7033c3a

Please sign in to comment.