diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 40a52b16628b3..beb4db625716e 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -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']; diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php index 6b396624556ca..20f68dfaaae36 100644 --- a/lib/public/IConfig.php +++ b/lib/public/IConfig.php @@ -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 */ @@ -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); }