mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 10:10:49 -04:00
feat(config): return whether a user config was actually deleted
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
e22914b5ff
commit
9b1c404ba3
3 changed files with 11 additions and 4 deletions
|
|
@ -1539,10 +1539,11 @@ class UserConfig implements IUserConfig {
|
|||
* @param string $userId id of the user
|
||||
* @param string $app id of the app
|
||||
* @param string $key config key
|
||||
* @return bool whether the value was deleted
|
||||
*
|
||||
* @since 31.0.0
|
||||
*/
|
||||
public function deleteUserConfig(string $userId, string $app, string $key): void {
|
||||
public function deleteUserConfig(string $userId, string $app, string $key): bool {
|
||||
$this->assertParams($userId, $app, $key);
|
||||
$this->matchAndApplyLexiconDefinition($userId, $app, $key);
|
||||
|
||||
|
|
@ -1551,11 +1552,13 @@ class UserConfig implements IUserConfig {
|
|||
->where($qb->expr()->eq('userid', $qb->createNamedParameter($userId)))
|
||||
->andWhere($qb->expr()->eq('appid', $qb->createNamedParameter($app)))
|
||||
->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($key)));
|
||||
$qb->executeStatement();
|
||||
$affectedRows = $qb->executeStatement();
|
||||
|
||||
unset($this->lazyCache[$userId][$app][$key]);
|
||||
unset($this->fastCache[$userId][$app][$key]);
|
||||
unset($this->valueDetails[$userId][$app][$key]);
|
||||
|
||||
return $affectedRows > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -687,10 +687,11 @@ interface IUserConfig {
|
|||
* @param string $userId id of the user
|
||||
* @param string $app id of the app
|
||||
* @param string $key config key
|
||||
* @return bool whether the value was deleted
|
||||
*
|
||||
* @experimental 31.0.0
|
||||
*/
|
||||
public function deleteUserConfig(string $userId, string $app, string $key): void;
|
||||
public function deleteUserConfig(string $userId, string $app, string $key): bool;
|
||||
|
||||
/**
|
||||
* Delete config values from all users linked to a specific config keys
|
||||
|
|
|
|||
|
|
@ -1704,7 +1704,10 @@ class UserConfigTest extends TestCase {
|
|||
|
||||
$userConfig = $this->generateUserConfig($preload ?? []);
|
||||
$this->assertEquals(true, $userConfig->hasKey($userId, $app, $key, $lazy));
|
||||
$userConfig->deleteUserConfig($userId, $app, $key);
|
||||
$deleted = $userConfig->deleteUserConfig($userId, $app, $key);
|
||||
self::assertTrue($deleted, 'user config was deleted');
|
||||
$deletedAgain = $userConfig->deleteUserConfig($userId, $app, $key);
|
||||
self::assertFalse($deletedAgain, 'user config can not be deleted twice');
|
||||
$this->assertEquals(false, $userConfig->hasKey($userId, $app, $key, $lazy));
|
||||
$userConfig = $this->generateUserConfig($preload ?? []);
|
||||
$this->assertEquals(false, $userConfig->hasKey($userId, $app, $key, $lazy));
|
||||
|
|
|
|||
Loading…
Reference in a new issue