aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-01-26 20:58:39 +0100
committerCarl Schwan <carl@carlschwan.eu>2022-05-12 21:02:52 +0200
commiteef973e85ba5e5cc322079ff85a599d42f1334e6 (patch)
tree23d99edd8f57e07973ae1327a67bab3c47f6b1c1 /lib/private
parenteb45a6ca404524bad6416ba3b3a755f9faa5e9b8 (diff)
downloadnextcloud-server-eef973e85ba5e5cc322079ff85a599d42f1334e6.tar.gz
nextcloud-server-eef973e85ba5e5cc322079ff85a599d42f1334e6.zip
Minor optimizations for saving user personal information
* Remove double hook: the OC_User::changeUser triggers an OC\AccountManager::userUpdated and the app is already listening to this signal in its Application definition * Make createCard not check if an card exists if we already checked previously. We also don't try to get the card if the user is disabled as we don't use the card in this case We this change we go from 100 DB requests to 80 DB requests when saving an user email address. Signed-off-by: Carl Schwan <carl@carlschwan.eu> (cherry picked from commit c6fd482edf33214a9ad4787e4cac278f871fa7c8)
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Accounts/AccountManager.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 5792ba1dc5d..7f79ab46c37 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -269,12 +269,15 @@ class AccountManager implements IAccountManager {
}
}
- protected function updateUser(IUser $user, array $data, bool $throwOnData = false): array {
- $oldUserData = $this->getUser($user, false);
+ protected function updateUser(IUser $user, array $data, ?array $oldUserData, bool $throwOnData = false): array {
+ if ($oldUserData === null) {
+ $oldUserData = $this->getUser($user, false);
+ }
+
$updated = true;
if ($oldUserData !== $data) {
- $this->updateExistingUser($user, $data);
+ $this->updateExistingUser($user, $data, $oldUserData);
} else {
// nothing needs to be done if new and old data set are the same
$updated = false;
@@ -601,12 +604,9 @@ class AccountManager implements IAccountManager {
}
/**
- * update existing user in accounts table
- *
- * @param IUser $user
- * @param array $data
+ * Update existing user in accounts table
*/
- protected function updateExistingUser(IUser $user, array $data): void {
+ protected function updateExistingUser(IUser $user, array $data, array $oldData): void {
$uid = $user->getUID();
$jsonEncodedData = $this->prepareJson($data);
$query = $this->connection->getQueryBuilder();
@@ -820,7 +820,7 @@ class AccountManager implements IAccountManager {
];
}
- $this->updateUser($account->getUser(), $data, true);
+ $this->updateUser($account->getUser(), $data, $oldData, true);
$this->internalCache->set($account->getUser()->getUID(), $account);
}
}