aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Accounts
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2021-10-22 22:03:29 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2021-10-22 23:05:43 +0200
commite26d6f080ba978fb4c40b7caf190714a67e2e80c (patch)
treef5c7eb6aaa7cd61fb22763417368dca9f9aff6f3 /lib/private/Accounts
parent6b099ecfe59402291b5915c928bfb16f4f9d6675 (diff)
downloadnextcloud-server-e26d6f080ba978fb4c40b7caf190714a67e2e80c.tar.gz
nextcloud-server-e26d6f080ba978fb4c40b7caf190714a67e2e80c.zip
fix populating account array with missing default values
- both $userData and $defaultUserData have numeric indices - each element contains at least the name and other fields - appending the missing data array is sufficient Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r--lib/private/Accounts/AccountManager.php13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 3416db56ba5..cbd51e71c4a 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -473,15 +473,16 @@ class AccountManager implements IAccountManager {
* Make sure that all expected data are set
*/
protected function addMissingDefaultValues(array $userData, array $defaultUserData): array {
- foreach ($defaultUserData as $i => $value) {
- // If property doesn't exists, initialize it
- if (!array_key_exists($i, $userData)) {
- $userData[$i] = [];
+ foreach ($defaultUserData as $defaultDataItem) {
+ // If property does not exist, initialize it
+ $userDataIndex = array_search($defaultDataItem['name'], array_column($userData, 'name'));
+ if ($userDataIndex === false) {
+ $userData[] = $defaultDataItem;
+ continue;
}
// Merge and extend default missing values
- $defaultValueIndex = array_search($value['name'], array_column($defaultUserData, 'name'));
- $userData[$i] = array_merge($defaultUserData[$defaultValueIndex], $userData[$i]);
+ $userData[$userDataIndex] = array_merge($defaultDataItem, $userData[$userDataIndex]);
}
return $userData;