Skip to content
Snippets Groups Projects
Unverified Commit dd185e38 authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Make sure limit is never negative


There were some cases where a negative limit could be passed in. Which
would happily make the query explode.

This is just a quick hack to make sure it never is negative.

Signed-off-by: default avatarRoeland Jago Douma <roeland@famdouma.nl>
parent 921f7489
No related branches found
No related tags found
No related merge requests found
......@@ -259,6 +259,8 @@ class Database extends ABackend
* @return array an array of all displayNames (value) and the corresponding uids (key)
*/
public function getDisplayNames($search = '', $limit = null, $offset = null) {
$limit = $this->fixLimit($limit);
$this->fixDI();
$query = $this->dbConn->getQueryBuilder();
......@@ -380,6 +382,8 @@ class Database extends ABackend
* @return string[] an array of all uids
*/
public function getUsers($search = '', $limit = null, $offset = null) {
$limit = $this->fixLimit($limit);
$users = $this->getDisplayNames($search, $limit, $offset);
$userIds = array_map(function ($uid) {
return (string)$uid;
......@@ -485,5 +489,11 @@ class Database extends ABackend
return $this->cache[$uid]['uid'];
}
private function fixLimit($limit) {
if (is_int($limit) && $limit >= 0) {
return $limit;
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment