Closed (fixed)
Project:
Simplenews
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Jan 2018 at 14:54 UTC
Updated:
16 Jul 2019 at 11:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dtv_rb commentedComment #3
disclose commentedYes, we have the same issue on our page. When using Simple News subscription functions from e.g. webhooks to add new subscribers it leads to an invalidation of cache_tags related to the Anonymous user (which in some cases invalidates nearly all pages).
Needs urgent attention.
Comment #4
berdirPatches welcome :)
Comment #5
dtv_rb commentedHere is a first patch.
Comment #6
mr.baileysI think it is prefered to use $user->isAuthenticated() instead of comparing the id. You could also roll the condition into the if-statement above.
While we are here, we could skip $user->save() if there are no shared fields (and thus no updates), and this not invalidating the cache for that user unless required?
Comment #7
subson commentedUpdating patch to use $user->isAuthenticated() and added condition for count($this->getUserSharedFields($user)) > 0 to run user->save() only if there are sharedfields.
Comment #8
berdirMakes sense, can we test this?
Comment #9
berdirI assume we are triggering this in our tests already when we update subscribers. search such case, assert that the anonymous user wasn't updated.
Also I think there is a better fix for it, we should instead check that we have a non-zero user ID in \Drupal\simplenews\Entity\Subscriber::getUser().
Comment #10
adamps commentedThere is an easy workaround to disable subscriber.sync_fields.
I'm unsure whether that whole feature is desirable/workable or should be removed in next major release #3049348: Problems with "Synchronize between account and subscriber fields"
Comment #11
adamps commentedThis was fixed by #3062530: Fix and simplify subscriber creation/lookup/sync patch #13 which included the improvement from comment #9.