aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2025-07-16 12:24:25 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2025-07-16 12:24:25 +0200
commit9b1c404ba3dbc4dd7d3adfd84e2cea08be4dc8ed (patch)
treec03799992f4ee56c03add31ee5a574938fc64de9
parente22914b5ff3f7720780f00c57fb8f88633e18d46 (diff)
downloadnextcloud-server-fix/config/return-user-config-deleted.tar.gz
nextcloud-server-fix/config/return-user-config-deleted.zip
feat(config): return whether a user config was actually deletedfix/config/return-user-config-deleted
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r--lib/private/Config/UserConfig.php7
-rw-r--r--lib/unstable/Config/IUserConfig.php3
-rw-r--r--tests/lib/Config/UserConfigTest.php5
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));