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 #2914110: Shortcut hook_toolbar implementation makes all pages uncacheable 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

Issue fork drupal-3426624

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

plopesc created an issue. See original summary.

plopesc’s picture

Title: Shortcuts Block does not take into account the user's default shortcut set » Shortcuts Block does not include the necessary cache tags
Issue summary: View changes
plopesc’s picture

Status: Active » Needs review

MR created

smustgrave made their first commit to this issue’s fork.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

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!

  • 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...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

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!

Status: Fixed » Closed (fixed)

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