Skip to content

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

Merged
MorrisJobke merged 1 commit into
stable12from
fix-own-avatar-not-updated-when-display-name-is-changed
Feb 27, 2018
Merged

[stable12] Fix own avatar not updated when display name is changed#8130
MorrisJobke merged 1 commit into
stable12from
fix-own-avatar-not-updated-when-display-name-is-changed

Conversation

@danxuliu

Copy link
Copy Markdown
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>
@danxuliudanxuliu added bug 3. to review Waiting for reviews labels Jan 31, 2018
@danxuliudanxuliu added this to the Nextcloud 12.0.6 milestone Jan 31, 2018
@codecov

codecovBot commented Jan 31, 2018

Copy link
Copy Markdown

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 FilesCoverage ΔComplexity Δ
lib/private/AvatarManager.php73.33% <100%> (+11.42%)9 <4> (+5)⬆️
lib/private/Files/Cache/Propagator.php96.2% <0%> (+1.26%)16% <0%> (ø)⬇️

@MorrisJobkeMorrisJobke left a comment

Copy link
Copy Markdown
Member

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 stable12Feb 27, 2018
@MorrisJobke
MorrisJobke deleted the fix-own-avatar-not-updated-when-display-name-is-changed branch February 27, 2018 17:40
@MorrisJobkeMorrisJobke mentioned this pull request Mar 9, 2018
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@danxuliu@rullzer@MorrisJobke