Skip to content

Commit 9c1b8e3

Browse files
committed
Fix #689
Solution is based off of one in da8d86a
1 parent d78a3a5 commit 9c1b8e3

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

types/User.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,31 @@ public function handleAjax()
8181
if ($max <= 0) return [];
8282

8383
// find users by login, fill up with names if wanted
84-
$logins = (array)$auth->retrieveUsers(0, $max, ['user' => $lookup]);
84+
// Because a value might be interpreted as integer in the
85+
// array key, we temporarily pad each key with a space at the
86+
// end to enforce string keys.
87+
$pad_keys = function ($logins) {
88+
$result = [];
89+
foreach ($logins as $login => $info) {
90+
$result["$login "] = $info;
91+
}
92+
return $result;
93+
};
94+
$logins = $pad_keys($auth->retrieveUsers(0, $max, ['user' => $lookup]));
8595
if ((count($logins) < $max) && $this->config['autocomplete']['fullname']) {
86-
$logins = array_merge($logins, (array)$auth->retrieveUsers(0, $max, ['name' => $lookup]));
96+
$logins = array_merge(
97+
$logins,
98+
$pad_keys($auth->retrieveUsers(0, $max, ['name' => $lookup]))
99+
);
87100
}
88101

89102
// reformat result for jQuery UI Autocomplete
90103
$users = [];
91104
foreach ($logins as $login => $info) {
105+
$true_login = substr($login, 0, -1);
92106
$users[] = [
93-
'label' => $info['name'] . ' [' . $login . ']',
94-
'value' => $login
107+
'label' => $info['name'] . ' [' . $true_login . ']',
108+
'value' => $true_login
95109
];
96110
}
97111

0 commit comments

Comments
 (0)