Issue #3426626: ShortcutsNavigationBlock is not being cached properly
Closes #3426626
Merge request reports
Activity
added 1 commit
added 1 commit
added 1 commit
added 1 commit
added 1 commit
added 4 commits
-
b3482081...b15058ac - 3 commits from branch
project:1.x
- c7dc897f - Merge remote-tracking branch 'origin/1.x' into 3426626-shortcutsnavigationblock-cache
-
b3482081...b15058ac - 3 commits from branch
- Resolved by Cristina Chumillas
65 // shortcut module in the future, so this would not be a problem anymore. 66 $shortcuts_links = \Drupal::service('shortcut.lazy_builders')->lazyLinks(); 67 if (!isset($shortcuts_links['shortcuts']['#links'])) { 68 return []; 69 } 70 $shortcuts_items = [ 71 [ 72 'title' => $this->configuration['label'], 73 'class' => 'shortcuts', 74 'below' => $shortcuts_links['shortcuts']['#links'], 73 return [ 74 '#lazy_builder' => ['navigation.shortcut_lazy_builder:lazyLinks', [$this->configuration['label']]], 75 '#create_placeholder' => TRUE, 76 '#cache' => [ 77 'keys' => ['shortcut_set_navigation_links'], 78 'contexts' => ['user'], My understanding of the issue here is such that, this is key, eg. that prior we were not taking the user into account, and caching without regard for the current user, hence, among multiple users, they would all see whoever was first to render. Is that correct?
Do we need the
keys
? Locally I see that it still works without it. I'm a bit rusty on the meaning ofkeys
, but IIRC by specifying keys, we're saying to the cacheing system to cache this render array, which since is being lazily built, I'm not sure how much value there is to it being render cached?To be honest, this is the 1st time I use
keys
in cache arrays. I was not sure whether this is completely required or not, but I followed the approach taken inshortcut_toolbar()
.Tried to find some docs about the topic, but I was unable to find anything that could help me to decide whether it was necessary or not.
Edited by Pablo López