From 1603cdc8d2798ddc2799a75deaf42b58515f84cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 20 Jun 2023 15:10:39 +0200 Subject: [PATCH] Fix since annotations and add boolean return type for setUserEnabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/User_LDAP.php | 3 ++- apps/user_ldap/lib/User_Proxy.php | 4 ++-- lib/private/User/User.php | 6 +++--- lib/public/User/Backend/IProvideEnabledStateBackend.php | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index fcd5a009e413e..d4a851bd7aa7e 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -677,7 +677,8 @@ public function isUserEnabled(string $uid, callable $queryDatabaseValue): bool { } } - public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): void { + public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool { $setDatabaseValue($enabled); + return $enabled; } } diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php index c95329cebed60..e0f1bb2d522af 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -458,7 +458,7 @@ public function isUserEnabled(string $uid, callable $queryDatabaseValue): bool { return $this->handleRequest($uid, 'isUserEnabled', [$uid, $queryDatabaseValue]); } - public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): void { - $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]); + public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool { + return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]); } } diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 3b7123bd5751d..edaab879ef7be 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -438,7 +438,7 @@ public function isEnabled() { $enabled = $this->config->getUserValue($this->uid, 'core', 'enabled', 'true'); $this->enabled = $enabled === 'true'; } - return (bool) $this->enabled; + return $this->enabled; }; if ($this->backend instanceof IProvideEnabledStateBackend) { return $this->backend->isUserEnabled($this->uid, $queryDatabaseValue); @@ -464,9 +464,9 @@ public function setEnabled(bool $enabled = true) { $enabled = $this->config->getUserValue($this->uid, 'core', 'enabled', 'true'); $this->enabled = $enabled === 'true'; } - return (bool) $this->enabled; + return $this->enabled; }; - $this->backend->setUserEnabled($this->uid, $enabled, $queryDatabaseValue, $setDatabaseValue); + $enabled = $this->backend->setUserEnabled($this->uid, $enabled, $queryDatabaseValue, $setDatabaseValue); if ($oldStatus !== $enabled) { $this->triggerChange('enabled', $enabled, $oldStatus); } diff --git a/lib/public/User/Backend/IProvideEnabledStateBackend.php b/lib/public/User/Backend/IProvideEnabledStateBackend.php index 143eca548ab92..8a4755ffbef0b 100644 --- a/lib/public/User/Backend/IProvideEnabledStateBackend.php +++ b/lib/public/User/Backend/IProvideEnabledStateBackend.php @@ -27,21 +27,21 @@ namespace OCP\User\Backend; /** - * @since 26.0.0 + * @since 28.0.0 */ interface IProvideEnabledStateBackend { /** - * @since 26.0.0 + * @since 28.0.0 * * @param callable():bool $queryDatabaseValue A callable to query the enabled state from database */ public function isUserEnabled(string $uid, callable $queryDatabaseValue): bool; /** - * @since 26.0.0 + * @since 28.0.0 * * @param callable():bool $queryDatabaseValue A callable to query the enabled state from database * @param callable(bool):void $setDatabaseValue A callable to set the enabled state in the database. */ - public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): void; + public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool; }