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 Mar 22, 2022
1 parent 79f1728 commit 25750aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 10 additions & 7 deletions lib/private/AllConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,22 +478,25 @@ 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();

$sql = 'SELECT `userid` FROM `*PREFIX*preferences` ' .
'WHERE `appid` = ? AND `configkey` = ? ';

if ($this->getSystemValue('dbtype', 'sqlite') === 'oci') {
//oracle hack: need to explicitly cast CLOB to CHAR for comparison
$sql .= 'AND to_char(`configvalue`) = ?';
if ($value !== null) {
if ($this->getSystemValue('dbtype', 'sqlite') === 'oci') {
//oracle hack: need to explicitly cast CLOB to CHAR for comparison
$sql .= 'AND to_char(`configvalue`) = ?';
} else {
$sql .= 'AND `configvalue` = ?';
}
$result = $this->connection->executeQuery($sql, [$appName, $key, $value]);
} else {
$sql .= 'AND `configvalue` = ?';
$result = $this->connection->executeQuery($sql, [$appName, $key]);
}

$result = $this->connection->executeQuery($sql, [$appName, $key, $value]);

$userIDs = [];
while ($row = $result->fetch()) {
$userIDs[] = $row['userid'];
Expand Down
6 changes: 3 additions & 3 deletions lib/public/IConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,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 @@ -245,9 +245,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 25750aa

Please sign in to comment.