Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce adressbook change events and handling #17001

Merged
merged 2 commits into from
Oct 1, 2019

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented Sep 4, 2019

This was observed when updating the Avatar from LDAP.

When setting a new avatar against the IAvatar::set() implementation, first the old avatar is removed. That cleans up the files and does some config settings. However, this cause also the addressbook to be updated with an empty avatar.

Then, when the new avatar is set, this happened again.

Now on LDAP this happened twice due to a wrong passOn parameter in the LDAP's proxy, which would lead to do it twice.

It can be easily reproduced:

  • have LDAP configured
  • log in with an LDAP user that gets it avatar from LDAP
  • open the personal settings page
  • run SQL query select count(*) from oc_addressbookchanges
  • refresh the personal settings page

Observed behaviour: the changes count is +4

Desired behaviour: the changes count is +1 (with this patch)

Now you could argue there should be no change when the avatar is still the same and there you are right. There will be a follow up, because that solution might cover the deeper buried behaviour.

... from four to one on avatar updates

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Copy link
Member

@georgehrke georgehrke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an LDAP to test, but code wise this looks fine 👍

I'm ok with this as a hot fix, but it should stay a hot fix and not become the permanent solution.

@kesselb
Copy link
Contributor

kesselb commented Sep 4, 2019

Code looks good 👍 Don't have a ldap setup either 🙈

server/lib/private/Server.php

Lines 1236 to 1237 in 7927aeb

$avatar = $manager->getAvatar($user->getUID());
$avatar->remove();

Here is another place for the follow up. If we are going to delete the user anyway we don't have to trigger a change. This might save some calls.

@blizzz
Copy link
Member Author

blizzz commented Sep 4, 2019

I'm ok with this as a hot fix, but it should stay a hot fix and not become the permanent solution.

can you elaborate?

blizzz added a commit that referenced this pull request Sep 4, 2019
* avoids useless FS operation
* avoids useless DB writes
* avoids useless addressbook updates
* addendum to #17001

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@rullzer rullzer mentioned this pull request Sep 4, 2019
16 tasks
@georgehrke
Copy link
Member

Why can't we replace it in one step. Is there really a need for remove and recreate?

@blizzz
Copy link
Member Author

blizzz commented Sep 5, 2019

Why can't we replace it in one step. Is there really a need for remove and recreate?

My understanding is that there are several different sized version of the avatar. Deleting them first ensures that no old one is left.

@blizzz blizzz requested a review from rullzer September 5, 2019 09:44
@rullzer rullzer modified the milestones: Nextcloud 17, Nextcloud 18 Sep 5, 2019
@rullzer
Copy link
Member

rullzer commented Sep 5, 2019

Master is no 18 development. If this needs to go into 17 please follow the normal backport procedures after merging.

@blizzz
Copy link
Member Author

blizzz commented Sep 5, 2019

/backport to stable17

@blizzz
Copy link
Member Author

blizzz commented Sep 5, 2019

/backport to stable16

@blizzz
Copy link
Member Author

blizzz commented Sep 20, 2019

still looking for another reviewer :)

Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐘

@blizzz blizzz merged commit 47ab961 into master Oct 1, 2019
@blizzz blizzz deleted the fix/noid/addressbookchanges-avatar branch October 1, 2019 10:17
@backportbot-nextcloud
Copy link

backport to stable17 in #17351

@backportbot-nextcloud
Copy link

backport to stable16 in #17352

backportbot-nextcloud bot pushed a commit that referenced this pull request Oct 2, 2019
* avoids useless FS operation
* avoids useless DB writes
* avoids useless addressbook updates
* addendum to #17001

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
backportbot-nextcloud bot pushed a commit that referenced this pull request Oct 2, 2019
* avoids useless FS operation
* avoids useless DB writes
* avoids useless addressbook updates
* addendum to #17001

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants