diff options
author | Joas Schilling <coding@schilljs.com> | 2025-04-17 09:38:49 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-04-17 09:50:12 +0200 |
commit | 1ada9910b10052e91809b111687e2713488fa6a6 (patch) | |
tree | 0acb6e8ac3e779cbcbc1ec62a9234a3900bb87a1 | |
parent | 775ca882f31df3663a8876952363070199c2816b (diff) | |
download | nextcloud-server-bugfix/noid/dont-break-when-checking-if-too-long-user-exists.tar.gz nextcloud-server-bugfix/noid/dont-break-when-checking-if-too-long-user-exists.zip |
fix(user): Introduce a public constant for max length of user idbugfix/noid/dont-break-when-checking-if-too-long-user-exists
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/private/User/DisplayNameCache.php | 5 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 9 | ||||
-rw-r--r-- | lib/public/IUser.php | 5 |
3 files changed, 10 insertions, 9 deletions
diff --git a/lib/private/User/DisplayNameCache.php b/lib/private/User/DisplayNameCache.php index 114ec3627dd..40e1c752589 100644 --- a/lib/private/User/DisplayNameCache.php +++ b/lib/private/User/DisplayNameCache.php @@ -11,6 +11,7 @@ use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\ICache; use OCP\ICacheFactory; +use OCP\IUser; use OCP\IUserManager; use OCP\User\Events\UserChangedEvent; use OCP\User\Events\UserDeletedEvent; @@ -24,8 +25,6 @@ use OCP\User\Events\UserDeletedEvent; * @template-implements IEventListener<UserChangedEvent|UserDeletedEvent> */ class DisplayNameCache implements IEventListener { - /** @see \OC\Config\UserConfig::USER_MAX_LENGTH */ - public const MAX_USERID_LENGTH = 64; private array $cache = []; private ICache $memCache; private IUserManager $userManager; @@ -40,7 +39,7 @@ class DisplayNameCache implements IEventListener { return $this->cache[$userId]; } - if (strlen($userId) > self::MAX_USERID_LENGTH) { + if (strlen($userId) > IUser::MAX_USERID_LENGTH) { return null; } diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index b26e6b3973a..ca5d90f8c00 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -53,9 +53,6 @@ use Psr\Log\LoggerInterface; * @package OC\User */ class Manager extends PublicEmitter implements IUserManager { - /** @see \OC\Config\UserConfig::USER_MAX_LENGTH */ - public const MAX_USERID_LENGTH = 64; - /** * @var UserInterface[] $backends */ @@ -121,7 +118,7 @@ class Manager extends PublicEmitter implements IUserManager { return $this->cachedUsers[$uid]; } - if (strlen($uid) > self::MAX_USERID_LENGTH) { + if (strlen($uid) > IUser::MAX_USERID_LENGTH) { return null; } @@ -184,7 +181,7 @@ class Manager extends PublicEmitter implements IUserManager { * @return bool */ public function userExists($uid) { - if (strlen($uid) > self::MAX_USERID_LENGTH) { + if (strlen($uid) > IUser::MAX_USERID_LENGTH) { return false; } @@ -726,7 +723,7 @@ class Manager extends PublicEmitter implements IUserManager { } // User ID is too long - if (strlen($uid) > self::MAX_USERID_LENGTH) { + if (strlen($uid) > IUser::MAX_USERID_LENGTH) { throw new \InvalidArgumentException($l->t('Login is too long')); } diff --git a/lib/public/IUser.php b/lib/public/IUser.php index 227e4f902c7..52f79083dc1 100644 --- a/lib/public/IUser.php +++ b/lib/public/IUser.php @@ -16,6 +16,11 @@ use InvalidArgumentException; */ interface IUser { /** + * @since 32.0.0 + */ + public const MAX_USERID_LENGTH = 64; + + /** * get the user id * * @return string |