The admin/content view page gets cached, but the operations column is different for the various users. When a user visits the page after the cache is cleared, their operations are correct. Another user, with the same role, may have different access to other nodes, but the result of the first user is shown => this leads to unwanted, in access denied resulting edit buttons.

I installed Views Custom Cache Tags and set the cache tag to user:[user:id], but it didnt work (looking at the module I'd guess it supports tokens).

How can I set that the output of admin/content is cached per user? I dont want to completely disable the cache for that view.

  • Yes, as you found out, this is a core bug and needs to be properly fixed there. you can't really work around it. – Berdir Jan 17 '17 at 16:42

This is not a cache tag issue. You need a cache context.

You can use a contextual filter for the user, then Views would add the cache context automatically.

Another option is to add the context to the render array of the View:

function mymodule_views_pre_render($view) {
  if ($view->id() == 'content') {
    $view->element['#cache']['contexts'][] = 'user';

The cache context user.permissions is used by default in drupal caching. If this doesn't give you the variations you need in cache use the more general user context. Then for each user a new version of the View is cached, which will obviously use more database space.

| improve this answer | |
  • thanks! i actually came this far myself, but still the operations would be wrong. it seems this is still an open bug: drupal.org/node/2473873 – Alex Jan 17 '17 at 13:30
  • Before the edit the question was about tags, now it's about a core issue. Think we'll have to wait until this is resolved. – 4k4 Jan 17 '17 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.