diff options
-rw-r--r-- | lib/private/Config/UserConfig.php | 7 | ||||
-rw-r--r-- | lib/unstable/Config/IUserConfig.php | 3 | ||||
-rw-r--r-- | tests/lib/Config/UserConfigTest.php | 5 |
3 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index fb0bf954f57..be1ec92e49f 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -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; } /** diff --git a/lib/unstable/Config/IUserConfig.php b/lib/unstable/Config/IUserConfig.php index b9cbb65ad03..196315a5cc6 100644 --- a/lib/unstable/Config/IUserConfig.php +++ b/lib/unstable/Config/IUserConfig.php @@ -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 diff --git a/tests/lib/Config/UserConfigTest.php b/tests/lib/Config/UserConfigTest.php index 2c8222576c4..eaa1ee8642a 100644 --- a/tests/lib/Config/UserConfigTest.php +++ b/tests/lib/Config/UserConfigTest.php @@ -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)); |