Skip to content

Commit

Permalink
IConfig::getUsersForUserValue() -- interprete null value as request t…
Browse files Browse the repository at this point in the history
…o fetch all users with given key set.
  • Loading branch information
rotdrop committed Jul 11, 2023
1 parent 7f71485 commit 78da528
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions lib/private/AllConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,20 +485,22 @@ public function getUserValueForUsers($appName, $key, $userIds) {
* @param string $value the value to get the user for
* @return array of user IDs
*/
public function getUsersForUserValue($appName, $key, $value) {
public function getUsersForUserValue($appName, $key, $value = null) {
// TODO - FIXME
$this->fixDIInit();

$qb = $this->connection->getQueryBuilder();
$result = $qb->select('userid')
$query = $qb->select('userid')
->from('preferences')
->where($qb->expr()->eq('appid', $qb->createNamedParameter($appName, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($key, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq(
->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($key, IQueryBuilder::PARAM_STR)));
if ($value !== null) {
$query->andWhere($qb->expr()->eq(
$qb->expr()->castColumn('configvalue', IQueryBuilder::PARAM_STR),
$qb->createNamedParameter($value, IQueryBuilder::PARAM_STR))
)->orderBy('userid')
->executeQuery();
);
}
$result = $query->orderBy('userid')->executeQuery();

$userIDs = [];
while ($row = $result->fetch()) {
Expand Down
6 changes: 3 additions & 3 deletions lib/public/IConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function getUserValue($userId, $appName, $key, $default = '');
*
* @param string $appName app to get the value for
* @param string $key the key to get the value for
* @param array $userIds the user IDs to fetch the values for
* @param null|array $userIds the user IDs to fetch the values for, all users with values if null
* @return array Mapped values: userId => value
* @since 8.0.0
*/
Expand Down Expand Up @@ -260,9 +260,9 @@ public function deleteAppFromAllUsers($appName);
*
* @param string $appName the app to get the user for
* @param string $key the key to get the user for
* @param string $value the value to get the user for
* @param null|string $value the value to get the user for, all users with set key if $value is null
* @return array of user IDs
* @since 8.0.0
*/
public function getUsersForUserValue($appName, $key, $value);
public function getUsersForUserValue($appName, $key, $value = null);
}

0 comments on commit 78da528

Please sign in to comment.