Timeline for Private tempstore storage contains data for previous anonymous user
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 22, 2020 at 8:00 | history | edited | 4uk4 | CC BY-SA 4.0 |
added 114 characters in body
|
Oct 22, 2020 at 8:00 | comment | added | 4uk4 | My answer is more about that you need to add a cache context, not where. So I've assumed you have a render element in the build array which displays a session value. If you add the session value in a different place I would suggest to add the cache data at the same place. Tokens can also bubble up cache metadata. But there are a lot of things that can go wrong if you have for example a custom token placed in a contrib/custom block rendered via a custom theme. | |
Oct 21, 2020 at 19:57 | comment | added | Miloš Kroulík |
Thanks. I added following hook implementation to my module: function mymodule_block_build_social_sharing_block_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) { $build['#cache']['contexts'][] = 'session'; } But it didn't help. Am I doing something wrong?
|
|
Oct 21, 2020 at 12:13 | comment | added | 4uk4 |
No, add the cache context directly to the build array the block plugin returns. session is a default auto placeholder condition and then the block cache methods no longer work. See drupal.stackexchange.com/questions/288881/…
|
|
Oct 21, 2020 at 12:03 | history | edited | 4uk4 | CC BY-SA 4.0 |
added 73 characters in body
|
Oct 21, 2020 at 11:56 | comment | added | Miloš Kroulík |
Thanks. So this basically means that I need to override this part of a block definition of the module? /** * {@inheritdoc} */ public function getCacheContexts() { return Cache::mergeContexts(parent::getCacheContexts(), ['url.path']); }
|
|
Oct 21, 2020 at 11:49 | history | answered | 4uk4 | CC BY-SA 4.0 |