Problem/Motivation
Over at #2254865-37: toolbar_pre_render() runs on every page and is responsible for ~15ms/17000 function calls it is impossible to add the cacheable metadata to the link itself.
Proposed resolution
- Add a new parameter for #theme => links, 'links' property to allow setting cacheability as a CacheableMetadata object (or render array) directly on the link.
Useful:
CacheableMetadata::fromRenderArray($cacheable_render_array)
->applyTo($link);
Or
$cacheable_metadata->applyTo($link);
directly (if using the object route).
Remaining tasks
- Do it
User interface changes
- None
API changes
- API addition to #theme links definition
Comment | File | Size | Author |
---|---|---|---|
#5 | interdiff.txt | 1.67 KB | Wim Leers |
#5 | type_links_cacheability_individual_links-2495779-5.patch | 2.35 KB | Wim Leers |
Comments
Comment #1
Wim LeersIsn't this what you want?
Comment #2
Wim Leers(#1 is not what the IS suggests, but AFAICT it's even better.)
Comment #3
Wim LeersComment #5
Wim LeersSo this unbreaks HEAD, because now
CommentPostRenderCache::attachNewCommentsLinkMetadata()
is being called again, and hence the last user of['#attached']['js']
is uncovered.Fixing it.
Comment #7
Fabianx CreditAttribution: Fabianx for Acquia commentedThe patches are for #2496399: Comment module's node links' front-end perf-optimizing drupalSettings are missing.
This approach here is for #theme => 'links' and has nothing to do with drupal_pre_render_links().