Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
\Drupal\media\Controller\OEmbedIframeController::render
calls $this->renderer->executeInRenderContext
but doesn't consider if any metadata was bubbled in the context.
Themes/modules can implement hook_preprocess
for media_oembed_iframe
and potentially inject additional attachments or cache metadata by modifying the #cache or #attached keys.
Steps to reproduce
Implement hook_preprocess_media_oembed_iframe
and either modify #attachments or #cache
Note that these changes don't bubble.
Proposed resolution
Inspect the context and if there is bubbling, respect it.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#8 | 3230772-8.patch | 5.22 KB | larowlan |
#8 | interdiff-a51d2a.txt | 1.03 KB | larowlan |
#6 | 3230772-6.patch | 4.87 KB | larowlan |
#6 | interdiff-a5b860.txt | 2.3 KB | larowlan |
#2 | 3230772-pass.patch | 4.36 KB | larowlan |
Comments
Comment #2
larowlanPass/fail
Comment #3
larowlanComment #5
phenaproximaTwo questions.
$variables['#attached']
is something I've never seen. I thought that we had to attach things to specific render elements, rather than entire variable arrays passed to preprocess hooks. Could you perchance point me to the place where the theme system handles$variables['#attached']
?Comment #6
larowlan1. See https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/lib/Drupal/C... - basically if any preprocess function changes #cache or #attachments, then this bubbles
2. Done
Comment #7
phenaproximaOne small request: can you add a blank line above this, plus a comment to explain what it's doing (which, as I understand it, boils down to preserving attachments and cacheable metadata added during the trip through the render system)? When that's done, this is RTBC as far as I'm concerned.
Comment #8
larowlanDone
Comment #9
phenaproximaComplaints remaining: zero. Cut and print!
Comment #10
phenaproximaI think this qualifies as a bug, so I'm tagging it for the Bug Smash Initiative.
Comment #11
acConfirming this both works and solves a problem. +1
Comment #12
alexpottCommitted and pushed 0cbd31dbb8 to 9.3.x and 5b2ffba9f2 to 9.2.x. Thanks!
This looks like a neat and self-contained bug fix. Backporting to 9.2.x