Shortcuts Block does not include the necessary cache tags

Created on 8 March 2024, 9 months ago
Updated 26 March 2024, 8 months ago

Problem/Motivation

Shortcuts Block cache is not taking into account the user preferences and shows the 1st user to load shortcut set and then it is cached for every user in the same role.

Steps to reproduce

  1. Install default Standard Drupal installation
  2. Create new Shortcut sets X, Y and add some links
  3. Create 2 Users, A and B and assign them the same role, including "access shortcuts" permission
  4. Login as User A and set the Y shortcut set as the preferred one
  5. Login as User B and set the X shortcut set as the preferred one
  6. Place the shortcuts block in the site
  7. Visit the page containing the block as User A, so the Y shortcut set is shown
  8. Login as User B and visit the same page
  9. Shortcuts block shows the Y shortcut set instead of the expected X shortcut set

Proposed resolution

Implement a similar solution as proposed in πŸ› Shortcut hook_toolbar implementation makes all pages uncacheable Fixed for the toolbar shortcut links.
They should respect the current user preferences.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

10.3 ✨

Component
ShortcutΒ  β†’

Last updated about 2 months ago

  • Maintained by
  • πŸ‡΅πŸ‡°Pakistan @jibran
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
  • Merge request !6990Resolve #3426624 "Shortcuts block cache" β†’ (Open) created by plopesc
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid
  • Status changed to Needs review 9 months ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    MR created

  • Pipeline finished with Success
    9 months ago
    Total: 539s
    #116310
  • First commit to issue fork.
  • Status changed to RTBC 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Ran the test-only feature

    1) Drupal\Tests\shortcut\Functional\ShortcutCacheTagsTest::testBlock
    Failed asserting that two arrays are identical.
    --- Expected
    +++ Actual
    @@ @@
         0 => 'languages:language_interface'
         1 => 'theme'
         2 => 'url.query_args:_wrapper_format'
    -    3 => 'user'
    +    3 => 'user.permissions'
    +    4 => 'user.roles:authenticated'
     )
    /builds/issue/drupal-3426624/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:121
    /builds/issue/drupal-3426624/vendor/phpunit/phpunit/src/Framework/Constraint/IsIdentical.php:79
    /builds/issue/drupal-3426624/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php:155
    /builds/issue/drupal-3426624/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php:289
    /builds/issue/drupal-3426624/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
    FAILURES!
    Tests: 4, Assertions: 194, Failures: 1.
    

    Was able to reproduce the issue and the MR did solve the problem for me.

    LGTM!

  • Pipeline finished with Running
    9 months ago
    Total: 588s
    #116509
    • catch β†’ committed ee03e025 on 10.3.x
      Issue #3426624 by plopesc, smustgrave: Shortcuts Block does not include...
    • catch β†’ committed 6ef8c1e2 on 11.x
      Issue #3426624 by plopesc, smustgrave: Shortcuts Block does not include...
  • Status changed to Fixed 8 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Looks good to me, nice to see it can just re-use the existing lazy builder.

    Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024