Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
media system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Nov 2023 at 20:11 UTC
Updated:
3 Mar 2024 at 10:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mfbIt seems like there isn't enough error logging here to really be able to debug what's going on.
Here's a patch to improve logging somewhat (although, maybe still not enough, depending what the exception message is :)
Comment #3
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #4
dadderley commentedThanks mfb, have applied the patch.
Waiting for new errors.
Comment #5
dadderley commentedFurther update.
The patch adds to the error message.
Could not retrieve the remote URL (https://youtu.be/ZwEYpptNyek): Could not retrieve the oEmbed resource.In a browser where I am not logged in I go the affected page with the embedded video.
Of course the video does not show.
I visit the same page in as a logged in user.
The video shows.
I flush the caches.
I return to the page In a browser where I am not logged in.
The video shows now whereas it did not show before.
Interesting caching issue looks like.
I do not drupal core caching enabled.
I have advaag disabled.
I am using redis and I am using cloudflare.
Any ideas?
Comment #6
mfbThere's hopefully another exception inside with a better error message? Here's another patch.
Contrib loggers that can show nested exceptions make debugging a lot easier than drupal core on its own.
Comment #7
dadderley commentedApplied the patch.
The error message now reads.
Could not retrieve the remote URL (https://youtu.be/Fw6Rz2GAxc0): cURL error 28: Resolving timed out after 5000 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://www.youtube.com/oembed?url=https://youtu.be/Fw6Rz2GAxc0&maxwidth=560&maxheight=315So this looks helpful.
Are there any quick fixes for this?
Thanks in advance.
As a non coder, this whole thing is pure voodoo.
As this seems to happen mostly for anon users and authenticated users see the video.
Comment #8
mfbFrom here, it'll be up to you to figure out by talking to whoever is responsible for the network where your site is hosted. You now have an error you can show them - it should not take over 5000 milliseconds to resolve www.youtube.com - maybe the DNS server you are using is over-saturated, or caching needs to be enabled, or something like that.
This logging change might be worthwhile for other folks who are debugging this component, so I'll set the patch to "needs review"
Comment #9
smustgrave commentedThis seems more like a support request ticket
Comment #10
dadderley commentedThanks for the good advice.
I talked to the server admin and he seems to have fixed this issue.
This is his explanation of what was going on.
Comment #11
mfb@smustgrave what do you think about the patch - this is rather difficult to debug unless the logging is improved.
Comment #12
smustgrave commentedSo this could be repurposed with an updated title and issue summary.
New ticket opened up and this one is postponed on that.
Either or.
Comment #13
mfbComment #14
smustgrave commentedSo revisting this and seems the request is to add additional logging information for possible future debugging or issues. On that idea +1 from me.
Comment #15
sachinsnimbalkar@gmail.com commentedI have created the twig file based on my content type template/field/field--node--field-article-video--article.html.twig
with following code and
{#
/**
* @file
* Default template for a field.
*/
#}
{% if gallery_video_thumbURL %}
{% else %}
{% for item in items %}
{{ item.content }}
{% endfor %}
{% endif %}
In my theme file created function
function extractYouTubeVideoID($url) {
// Regular expression pattern to match YouTube video IDs
$pattern = '/(?<=watch\?v=|\/videos\/|embed\/|youtu.be\/|\/v\/|\/e\/|watch\?v%3D|\?v%3D)([\w-]{11})/i';
// Perform the regular expression match
preg_match($pattern, $url, $matches);
// Check if the video ID is found and return it, or return null if not found
return isset($matches[1]) ? $matches[1] : null;
}
function crystalrun_preprocess_field(&$variables) {
$entity = \Drupal::routeMatch()->getParameter('node');
if ($entity instanceof \Drupal\node\NodeInterface) { // Check if it is a node
$nid = $entity->id(); // You also have the node object right here$
$node = \Drupal\node\Entity\Node::load($nid);
$content_type= $node->getType();
/**********/
if ($content_type == "article"){
// check the field value exits or not.
$url = $node->field_article_video->getValue();
if (!empty($url))
{
$field_value = $node->field_article_video->entity->field_media_oembed_video->getValue()[0]['value'];
$videoID = extractYouTubeVideoID($field_value);
$variables['gallery_video_thumbURL'] = 'https://www.youtube.com/embed/'.$videoID ? 'https://www.youtube.com/embed/'.$videoID :'' ;
}else
{
$variables['gallery_video_thumbURL']="";
}
}
/*********/
}
Its absolutely working fine for me, please share you feedback and comment on the resolution, can be used with other contenttype simillary be creating twig file and handling the logic.
Comment #16
quietone commentedCan we have some tests of this new message?
Comment #18
mfbI'm not super familiar with media module, so not sure this is the best place for it, but here is a hopefully a working test
Comment #19
smustgrave commentedRestoring status as test coverage is there https://git.drupalcode.org/issue/drupal-3402540/-/jobs/555070
Comment #20
longwaveMade a suggestion to improve the test.
Comment #21
mfbComment #22
smustgrave commentedFeedback appears to be addressed
Comment #23
longwaveNot eligible for backport as it changes a user-facing string.
Committed 8f38fc7 and pushed to 11.x. Thanks!