diff options
author | Vincent Petry <vincent@nextcloud.com> | 2021-03-24 17:06:04 +0100 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2021-03-26 13:07:09 +0100 |
commit | b73df5846ce9c801e93e79e11e93a8cd73dabfdd (patch) | |
tree | 2eae53805cae60507932fe83d58dc5c097be2b05 /lib/private/Accounts | |
parent | cb9d25c1629251e3b972582a97ed981b316a6d7e (diff) | |
download | nextcloud-server-b73df5846ce9c801e93e79e11e93a8cd73dabfdd.tar.gz nextcloud-server-b73df5846ce9c801e93e79e11e93a8cd73dabfdd.zip |
Add property scope tests for AccountManager
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 74ba53737ca..6198f8dbddd 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -165,13 +165,18 @@ class AccountManager implements IAccountManager { $propertyData['scope'] === self::SCOPE_PRIVATE && ($propertyName === self::PROPERTY_DISPLAYNAME || $propertyName === self::PROPERTY_EMAIL) ) { - // v2-private is not available for these fields - throw new \InvalidArgumentException('scope'); + if ($throwOnData) { + // v2-private is not available for these fields + throw new \InvalidArgumentException('scope'); + } else { + // default to local + $data[$propertyName]['scope'] = self::SCOPE_LOCAL; + } + } else { + // migrate scope values to the new format + // invalid scopes are mapped to a default value + $data[$propertyName]['scope'] = AccountProperty::mapScopeToV2($propertyData['scope']); } - - // migrate scope values to the new format - // invalid scopes are mapped to a default value - $data[$propertyName]['scope'] = AccountProperty::mapScopeToV2($propertyData['scope']); } } @@ -229,6 +234,8 @@ class AccountManager implements IAccountManager { * * @param IUser $user * @return array + * + * @deprecated use getAccount instead to make sure migrated properties work correctly */ public function getUser(IUser $user) { $uid = $user->getUID(); |