Add cache expiry on avatar creation/removal
Created by: dblessing
This PR resolves #5496 (closed). If you add/remove an avatar the events cache is not updated and results in either a broken image or shows a gravatar instead of the avatar - see screenshots below. By adding a cache "expire/update" on both avatar creation/removal we can eliminate this issue. I took the approach of updating events by author id only and set it to limit to 1000 items. I'm not sure if this is the right limit or if a limit is warranted, but a similar cache reset for projects limits to 100 items. 100 seemed too low in this case because we have to expect that this user will have many events across multiple projects.
Steps to test (Please note that you cannot test this fix in a development environment without enabling caching)
- Add an avatar
- Go to the dashboard and note that the avatars on events are either still showing the gravatar or are showing a broken image link
- Apply this fix
- Change the avatar
- Go to the dashboard and note that the avatars are now showing the new image. Similarly, you can remove the avatar and note that gravatars are now shown on all events.
Illustration of the issue when an avatar is uploaded. You still see the gravatar/default avatar image:
Illustration of the issue when a user already had an avatar and then changed it: