Skip to content
Snippets Groups Projects

Issue #3426626: ShortcutsNavigationBlock is not being cached properly

Issue #3426626: ShortcutsNavigationBlock is not being cached properly

Closes #3426626

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • m4olivei
  • 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 of keys, 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 in shortcut_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
    • Please register or sign in to reply
  • added 1 commit

    Compare with previous version

  • Pablo López added 1 commit

    added 1 commit

    Compare with previous version

  • Pablo López added 1 commit

    added 1 commit

    Compare with previous version

  • Cristina Chumillas started a merge train

    started a merge train

  • Please register or sign in to reply
    Loading