Active
Project:
Drupal core
Version:
main
Component:
node system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2026 at 11:16 UTC
Updated:
13 Jul 2026 at 11:16 UTC
Jump to comment: Most recent
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);
}
N/A
N/A
Remove the old code and deal with the fallout.
N/A
N/A
N/A
N/A
N/A
Comments