summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-03-24 17:06:04 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-03-29 07:03:35 +0000
commit73ec32d19bb1bc58f856e4f5bb4034204680fd36 (patch)
tree63dfa6b534530269db0c45b2ed1b6c059a2d3b3b /lib/private
parent2fd62b4f0dc71129ad39c44648fa63301608e455 (diff)
downloadnextcloud-server-73ec32d19bb1bc58f856e4f5bb4034204680fd36.tar.gz
nextcloud-server-73ec32d19bb1bc58f856e4f5bb4034204680fd36.zip
Add property scope tests for AccountManager
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Accounts/AccountManager.php19
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();