Api: Fix accounts list (Sql) would be empty after refresh if there were less than 50 accounts

- Fix some accounts backend were not returning results indexed by account ID
This commit is contained in:
nathangray 2021-05-21 09:16:25 -06:00
parent f266766b95
commit 35bc2ffe70
3 changed files with 5 additions and 5 deletions

View File

@ -256,7 +256,7 @@ class Accounts
$this->total = count($result); $this->total = count($result);
if (!empty($param['offset'])) if (!empty($param['offset']))
{ {
return array_slice($result, $param['start'], $param['offset']); return array_slice($result, $param['start'], $param['offset'], true);
} }
return $result; return $result;
} }
@ -267,8 +267,8 @@ class Accounts
// if we already have an unlimited search, we can always return only a part of it // if we already have an unlimited search, we can always return only a part of it
elseif (isset($account_search[$serial_unlimited])) elseif (isset($account_search[$serial_unlimited]))
{ {
$this->total = $account_search[$serial]['total']; $this->total = $account_search[$serial_unlimited]['total'];
return array_slice($account_search[$serial]['total']['data'], $param['start'], $param['offset']); return array_slice($account_search[$serial_unlimited]['data'], $param['start'], $param['offset'], true);
} }
// no backend understands $param['app'], only sql understands type owngroups or groupmemember[+memberships] // no backend understands $param['app'], only sql understands type owngroups or groupmemember[+memberships]
// --> do an full search first and then filter and limit that search // --> do an full search first and then filter and limit that search

View File

@ -993,7 +993,7 @@ class Ads
reset($sortedAccounts); reset($sortedAccounts);
if(is_numeric($start) && is_numeric($offset)) if(is_numeric($start) && is_numeric($offset))
{ {
return array_slice($sortedAccounts, $start, $offset); return array_slice($sortedAccounts, $start, $offset, true);
} }
//error_log(__METHOD__.'('.array2string($param).') returning all '.array2string($sortedAccounts)); //error_log(__METHOD__.'('.array2string($param).') returning all '.array2string($sortedAccounts));
return $sortedAccounts; return $sortedAccounts;

View File

@ -884,7 +884,7 @@ class Ldap
if(is_numeric($start) && is_numeric($offset)) if(is_numeric($start) && is_numeric($offset))
{ {
$account_search[$serial]['total'] = $this->total; $account_search[$serial]['total'] = $this->total;
return $account_search[$serial]['data'] = isset($totalcount) ? $sortedAccounts : array_slice($sortedAccounts, $start, $offset); return $account_search[$serial]['data'] = isset($totalcount) ? $sortedAccounts : array_slice($sortedAccounts, $start, $offset, true);
} }
return $sortedAccounts; return $sortedAccounts;
} }