ShortcutsNavigationBlock is not being cached properly

Created on 8 March 2024, 9 months ago
Updated 1 April 2024, 8 months ago

Problem/Motivation

While working on πŸ“Œ [PP-1] Add tests for ShortcutsNavigationBlock Postponed found an inconsistency with the shortcut navigation block cache, which was not respecting the user selection.

Found that it was related to how the block is caching results.

This is also an issue in core's shortcut block, so also created πŸ› Shortcuts Block does not include the necessary cache tags Fixed

For navigation, we should refactor the way the block is built and take a look into how it is built in shortcut_toolbar() function.

Steps to reproduce

Scenario #1

  • Install default Standard Drupal installation
  • Create new Shortcut sets X, Y and add some links
  • Create 2 Users, A and B and assign them the same role, including "access shortcuts" & "access navigation" permission.
  • Login as User A and set the Y shortcut set as the preferred one
  • Login as User B and set the X shortcut set as the preferred one
  • Install navigation module
  • Visit the page containing the block as User A, so the Y shortcut set is shown in the navigation bar
  • Login as User B
  • Navigation bar shows the Y shortcut set instead of the expected X shortcut set

Scenarion #2

  • Install default Standard Drupal installation
  • Expand the shortcuts sectio in the navigation bar and check the links present there
  • Go to /admin/config/user-interface/shortcut/manage/default/add-link and add Taxonomy as the name and /admin/structure/taxonomy as the path
  • Expand the shortcuts group and check if the new shortcut is added

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @plopesc
  • πŸ‡©πŸ‡ͺGermany rkoller NΓΌrnberg, Germany

    I probably ran into the same yesterday πŸ› A potential caching issue, newly added shortcuts are not directly show in the shortcuts group Active . Saw your issue about creating a test. When i wanted to post a comment to the aforementioned issue i've created now i've noticed that it got postpone on this issue here.

  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Thank you for the heads-up @rkoller!

    Issue you mentioned is a secondary effect of the caching issues in general.

    Let me rephrase this one to ensure both situations are solved here and we can close yours.

  • Assigned to plopesc
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Bump priority and assign to myself.

  • Status changed to Needs review 9 months ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid
  • Pipeline finished with Success
    9 months ago
    Total: 160s
    #116558
  • Status changed to Needs work 9 months ago
  • πŸ‡©πŸ‡ͺGermany rkoller NΓΌrnberg, Germany

    I've applied the MR to the latest version of of the Navigation module (1.x-dev@dev) on a install of Drupal 11.x-dev as well as on an install of Drupal 10.2.4.

    On both instances the changes from the MR are in place in code (i've cross checked to make sure) but functionally, when manually testing, the MR has no effect. On both instances i've tried to add a shortcut by clicking the star icon as well as manually adding a new shortcut via /admin/config/user-interface/shortcut/manage/default/customize. After adding the page isn't shown for each of the cases in the shortcuts group in the navigation sidebar, only /admin/config/user-interface/shortcut/manage/default/customize reflects the newly added shortcut. i've also tried by pressing the reload button with the pressed alt-key to clear caches on reload. The newly added shortcuts are still only showing after a drush cr is run. same behavior the other way around when you try to remove an existing shortcut (either via unchecking the star icon or deleting a shortcut on /admin/config/user-interface/shortcut/manage/default/customize) . i've tested in safari, firefox, and edge, all the same result. :/

  • Pipeline finished with Success
    9 months ago
    Total: 150s
    #116602
  • Pipeline finished with Success
    9 months ago
    Total: 151s
    #116619
  • Pipeline finished with Canceled
    9 months ago
    Total: 60s
    #116627
  • Pipeline finished with Success
    9 months ago
    Total: 169s
    #116628
  • Status changed to Needs review 9 months ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Thank you for your review @rkoller

    Could you please take a look now? Added back one of the missing cache tags.

  • Pipeline finished with Success
    9 months ago
    Total: 198s
    #116679
  • πŸ‡©πŸ‡ͺGermany rkoller NΓΌrnberg, Germany

    thank you for the quick followup @plopsec! at first something went wrong with the 11.x-dev instance, applying the recent changes, somehow those got not applied. noticed that after all the steps described in #7 were working properly with the 10.2.4 instance after applying the MR there as well. therefore i've completely removed the patch on the 11.x instance and then reapplied. after that the latest changes were in place as well there and also all the steps outlined in #7 working now properly. from a manual testing perspective i think things behave as expected now. i leave the status at needs review because i am not a developer and therefore not qualified for a code review.

  • Pipeline finished with Success
    8 months ago
    Total: 146s
    #118129
  • Pipeline finished with Failed
    8 months ago
    Total: 841s
    #120408
  • πŸ‡¨πŸ‡¦Canada m4olivei Grimsby, ON

    Wow, great find on this @plopesc!

    The fix works for me, I just left a couple of notes to check my understanding. See my comment about keys. I'm not sure we need that, but I'm open to it, as I saw my knowledge on keys use in caching is a bit rusty.

  • Status changed to Needs work 8 months ago
  • πŸ‡¨πŸ‡¦Canada m4olivei Grimsby, ON
  • Issue was unassigned.
  • Status changed to RTBC 8 months ago
  • πŸ‡¨πŸ‡¦Canada m4olivei Grimsby, ON

    On second thought, I see the core commit took the keys code, so lets not hold this up. It's an interesting nerd caching thought though.

    Thanks again!

  • First commit to issue fork.
  • Pipeline finished with Success
    8 months ago
    Total: 148s
    #122131
  • Pipeline finished with Success
    8 months ago
    Total: 158s
    #122209
  • Pipeline finished with Success
    8 months ago
    Total: 239s
    #122215
  • Status changed to Fixed 8 months ago
  • πŸ‡ͺπŸ‡ΈSpain ckrina Barcelona

    Thanks all, good catch!! Merged :)

  • Pipeline finished with Success
    8 months ago
    Total: 203s
    #122252
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Success
    6 months ago
    Total: 149s
    #192610
  • Pipeline finished with Success
    3 months ago
    Total: 3465s
    #254455
  • Pipeline finished with Success
    3 months ago
    Total: 352s
    #254850
  • Pipeline finished with Success
    3 months ago
    Total: 3471s
    #254858
Production build 0.71.5 2024