Problem/Motivation

Original issue: #3516034: Add cacheable metadata to SelectInterface and entity QueryInterface objects

We allowed queries to carry cacheable metadata. With that change, it is no longer necessary to render a render array with only cacheable metadata just so we can bubble it up to the response. We can now add said metadata directly to the query, and that metadata will be consumed by whoever triggered the query.

So in \Drupal\node\Hook\NodeDatabaseHooks::queryNodeAccessAlter(), the following code was added:

    // Add the grants cache context to the query.
    $contexts = ['user.node_grants:' . $op];
    if ($query instanceof RefinableCacheableDependencyInterface) {
      $query->addCacheContexts($contexts);
    }

So the following code should now be removed:

    // Bubble the 'user.node_grants:$op' cache context to the current render
    // context.
    $renderer = \Drupal::service('renderer');
    if ($renderer->hasRenderContext()) {
      $build = ['#cache' => ['contexts' => $contexts]];
      $renderer->render($build);
    }

Steps to reproduce

N/A

Proposed resolution

N/A

Remaining tasks

Remove the old code and deal with the fallout.

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Comments

kristiaanvandeneynde created an issue.