Problem/Motivation
This module is broken in Drupal 10, due to a change in Symfony/HttpFoundation. When you add media_oembed_control to a field and try to use one of the options, instead of loading the Oembed you get the Drupal site loaded inside the iframe, with an error.
The Watchdog log has this message:
Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Input value "media_oembed_control" contains a non-scalar value. in Symfony\Component\HttpKernel\HttpKernel->handle() (line 81 of /var/www/html/landmarks/dev-site/vendor/symfony/http-kernel/HttpKernel.php).
Steps to reproduce
Try to use this module on a Drupal 10 site.
Proposed resolution
Update to work with Symfony 5.1.
Remaining tasks
The offending line is actually line 34 of src/Controller/OEmbedIframeController.php :
$media_oembed_control = $request->query->get('media_oembed_control', NULL);
... based on https://github.com/symfony/symfony/pull/34363 , ->get() returns a string, but the media_oembed_control parameter is passing an array. I think with Symfony 5, this is no longer allowed.
The comments on the issue suggest you can substitute ->all() to get the same result:
$media_oembed_control = $request->query->all('media_oembed_control', NULL);
This change is working for me on a new D10 site. I'm not sure whether it works on D8/9.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | media-oembed-control-non-scalar-value-3363412-6.patch | 668 bytes | matthiasm11 |
| #5 | Screenshot 2023-08-29 at 12.35.36 PM.png | 1.86 MB | shailja179 |
Comments
Comment #2
lindsay.wils commentedJust tried this on D10 with the same issues. Your update fixes the issue. Any chance of a patch being released with this update?
Thanks in advance
Comment #3
lindsay.wils commentedAny update on a patch being created for this? This is unusable in D10.
Unfortunately I do not know how to create a patch, happy to try if there is a guide online somewhere?
Thanks
Comment #4
shailja179 commentedComment #5
shailja179 commentedI am not getting this error on Drupal 10. Embed video is playing with autoplay.
Give me steps for the error, i can provide the patch if there is issue.
See the screenshot.
Comment #6
matthiasm11 commentedI had the same issue. The creator of issue https://www.drupal.org/project/media_oembed_control/issues/3388686 also had the same issue.
Attached patch.
Comment #7
jacobbell84 commentedIs this patch backwards compatible with 8 and 9, or do we need to make a new Drupal 10 specific module release?
Comment #8
jacobbell84 commentedThis was handled as part of #3388686: Exception thrown when trying to render a remote video field
Comment #9
noah commentedThe fix for this appears to have been lost in the current beta—I'm seeing the error again, and src/Controller/OEmbedIframeController.php has regressed to
$request->query->get('media_oembed_control', NULL). The patch from 6 still applies and fixes the problem.The other fix from the patch at #3388686: Exception thrown when trying to render a remote video field has persisted, only this one appears to have regressed.
Comment #10
lamp5Confirmed. It is regression from this issue #3380731: YouTube live videos won't autoplay due to missing "mute" url parameter. Patch #6 works.
Comment #13
jacobbell84 commentedThanks all! I re-merged the patch.