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

[stable12] Fix own avatar not updated when display name is changed #8130

Merged

Conversation

danxuliu
Copy link
Member

The avatar endpoint returns the avatar image or, if the user has no avatar, the display name. In that later case the avatar is generated on the browser based on the display name. The avatar endpoint response is cached, so when the display name changes and the avatar is got again the browser could use the cached value, in which case it would use the same display name as before and the avatar would not change.

When the avatar is an image the cache is invalidated with the use of the version parameter, which is increased when the image changes. When the avatar cache was first introduced only the image avatars were cached, but it was later changed to cache all avatar responses to limit the requests made to the server. Thus, now the cache of the display name is invalidated too by increasing the version of the avatar if the display name changes and there is no explicit avatar set.

In Nextcloud 13 and current master the avatar is always generated by the server, so these changes should not be needed in those versions.

How to test this:

  • Open the personal settings (with a browser that respects the cache time suggested by the server)
    • If there is an avatar image, remove it and refresh the page
  • The avatar is the first letter of the display name of the user. Change the display name so it starts with a different letter and refresh the page; with this pull request the avatar is updated, without it the old letter is still shown.

The avatar endpoint returns the avatar image or, if the user has no
avatar, the display name. In that later case the avatar is generated on
the browser based on the display name. The avatar endpoint response is
cached, so when the display name changes and the avatar is got again the
browser could use the cached value, in which case it would use the same
display name as before and the avatar would not change.

When the avatar is an image the cache is invalidated with the use of
the "version" parameter, which is increased when the image changes. When
the avatar cache was first introduced only the image avatars were
cached, but it was later changed to cache all avatar responses to limit
the requests made to the server. Thus, now the cache of the display name
is invalidated too by increasing the version of the avatar if the
display name changes and there is no explicit avatar set.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@danxuliu danxuliu added bug 3. to review Waiting for reviews labels Jan 31, 2018
@danxuliu danxuliu added this to the Nextcloud 12.0.6 milestone Jan 31, 2018
@codecov
Copy link

codecov bot commented Jan 31, 2018

Codecov Report

Merging #8130 into stable12 will increase coverage by <.01%.
The diff coverage is 100%.

@@              Coverage Diff               @@
##             stable12    #8130      +/-   ##
==============================================
+ Coverage       53.84%   53.85%   +<.01%     
- Complexity      22761    22766       +5     
==============================================
  Files            1385     1385              
  Lines           87150    87159       +9     
  Branches         1331     1331              
==============================================
+ Hits            46926    46936      +10     
+ Misses          40224    40223       -1
Impacted Files Coverage Δ Complexity Δ
lib/private/AvatarManager.php 73.33% <100%> (+11.42%) 9 <4> (+5) ⬆️
lib/private/Files/Cache/Propagator.php 96.2% <0%> (+1.26%) 16% <0%> (ø) ⬇️

@rullzer rullzer requested a review from icewind1991 February 8, 2018 20:56
Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Tested and works

@MorrisJobke MorrisJobke merged commit 6f4b6be into stable12 Feb 27, 2018
@MorrisJobke MorrisJobke deleted the fix-own-avatar-not-updated-when-display-name-is-changed branch February 27, 2018 17:40
@MorrisJobke MorrisJobke mentioned this pull request Mar 9, 2018
2 tasks
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.

3 participants