Closed (fixed)
Project:
Media: YouTube
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jun 2011 at 18:21 UTC
Updated:
18 Sep 2012 at 16:31 UTC
Jump to comment: Most recent file
Comments
Comment #1
steinmb commentedYeah, I have also seen this, and the strange thing is I have one mirrored installation where my local copy is able to create the thumbnails and the other not. Makes me wonder if this is related to the server env.?
What PHP version are you using?
Comment #2
wjaspers commentedI think 5.3.2, but I'll have to check when I get back to the office. There shouldn't be any write restrictions, though, because I'm developing in a Win32 environment and imagecache doesn't have any trouble.
Comment #3
gkazhus commentedsame here
Comment #4
steinmb commentedI'm thinking out loud here, could this be a bug in the media module? I have not looked enough at the code to figure out who of the module that is responsible for storing the thumb. I also think this issue is similar #717704: On some web hosts, preview thumbnail image isn't generated I posted some debugging info. at #11
Comment #5
wjaspers commentedI couldn't get PHP5.3 to run on Win32 (there's a problem with PDO); but I tested both PHP5.2.12 and 5.2.17, neither worked.
Comment #6
wjaspers commented@steinmb, Thanks for the debugging info. It appears (from what you showed) that the media module is trying to generate a thumbnail by using a stream wrapper that isn't normally registered.
"youtube://v/" is an internal shortcut, and it doesn't look like the path is being translated to its full value. When PHP tries to incorporate that stream to generate the thumbnail, it doesn't know what to do with it.
I'm moving this into the Media queue since it's affecting more than one sub-module.
Comment #7
steinmb commentedTested PHP 5.3 and 5.2 in my local setup, without being able to recreate the problem. It only materialize on the live server :-/
Still willing to help out squash this bug, any hints where in media I should start digging?
Comment #8
steinmb commentedWe moved this down to the media module, bumping this up to major in hop for it to get some more eyeballs. Anyone got some idea where we could start digging? This is related or the same as #717704: On some web hosts, preview thumbnail image isn't generated.
Comment #9
wjaspers commentedI have a pretty good idea of where the problem is coming from now.
In the media_youtube/includes folder, the MediaYouTubeStreamWrapper.inc file contains:
There are several potential points of failure
1) The local-path is a stream name that doesn't actually exist in the filesystem (
$local_path = 'public://media-youtube/) and needs to be translated into a real filepath. The stream wrappers included with Drupal are used by this class (via inheritance) to tell PHP how to convert these stream names into local filepaths, but because this handler extends the MediaReadOnlyStreamWrapper, it may be restricting write calls (this is the most likely cause) entirely.2) Calling PHP's
copy()function with a remote stream (http://img.youtube.com/...) might get interrupted, or remote streams might not even be available--depending on the PHP environment your Drupal installation is in (although I believe Drupal requires them to function, but I could be wrong).3) Youtube isn't returning a header that includes the mime-type for thumbnails (why, I have no idea). If needed, it is up to the handler to determine the type of file it actually is. If the stream wrapper encounters any kind of problem here, this may explain why we're ending up with empty GIF's. (Even though we're writing a .jpe?g extension).
4) The local storage location (in your public Drupal filesystem) requires write access to put the thumbnails in. If your HTTPD process isn't permitted to write here, it will fail.
5) As far as I can tell, the thumbnail isn't pushed through the Image Styles handlers, so (if it does get the thumbnail) it will always be full-size and forcibly scaled down. If the Image Styles are used, but not as expected, it could cause a problem.. Looks like the thumbnail is pushed through immediately after its grabbed.6) A stream context might be required, and isn't being utilized (it would be the third parameter of copy()).
For the moment
I've put this back into the Media: youtube queue. It's entirely possible the Media module's "MediaReadOnlyStreamWrapper" isn't doing things the same way Drupal core does; but I wanted to try and identify the root cause starting where our problem seems to have begun. If information surfaces that tells us otherwise, we can switch queues again.
For documentation's sake, I closed the other issue also in the Media: Youtube issue queue. (http://drupal.org/node/717704)
In my situation
My sandbox is a development machine separate from my desktop. My company is utilizing a content-firewall which restricts some streaming media. I discovered the sandbox is restricted from accessing youtube in any form, whereas my desktop can. For some, this may be all that's occurring--and I'm willing to bet--exactly why my thumbnails are turning up as GIF's.
Comment #10
steinmb commentedThanks for a detailed feedback, time to drush en devel :)
Checked these variables in getLocalThumbnailPath(), and they seems OK.
3) Not sure about this when we also see this on Vimeo, and I do not think it is related to what API we use.
4) I think
file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);check, create dir, change permissions if it have/able to. (http://api.drupal.org/api/drupal/includes--file.inc/function/file_prepar...) and works OK. I also tried to remove 'files/media-youtube' and the code is able to recreate the it.5) That is correct, I have also seen this.
In my situation
I see this on a live production site running on greengeeks.com.
Todo
Make sure, when we get the thumbs created, that is also is able to clean them up. Right now they are just felt there after the stream is deleted.
Comment #11
wjaspers commentedThis could also be a potential problem: http://drupal.org/node/1060712#comment-4611216
It looks like file_styles_variable_get() is requesting system variables that don't exist and generating stream URI's that Drupal can't use.
Comment #12
steinmb commentedWould not surprise me that there bugs related to running default in private mode is is the least tested/used one. As the server I see the bug on though are running with public as default storage area so at least for me do I think it is unrelated.
I'm still is trying to get 1) in #9, I'll prob. need to read up on PHP objects ;) btw. found time to check
@copy($this->getOriginalThumbnailPath(), $local_path);by running the output drupal log
dd(($this->getOriginalThumbnailPath()), 'Image URL ');and the complete URL is correct, example http://img.youtube.com/vi/399hFkQYnV4/0.jpg.I'm trying to get where Styles fit in, if copy() does it thing should it copy the file that the URL points to and to where ever $local_path points to, right? Styles picks up these files, and run them through image module?
Comment #13
mototribe commentedI have the same issue, it doesn't save the youtube thumbnail.
Btw, I used media gallery on another site and youtube thumbnails work there. They are stored in sites/default/files/media-youtube
rather than sites/default/files/styles/thumbnail/public/media-youtube ...
Comment #14
wjaspers commented@steinmb, @mototribe
I have a feeling the variables requested from #11 are closest cause of this.
@steinmb,
The URL to retrieve from is accurate, but the local URI to save to appears to be wrong.
@mototribe,
The thumbnails in "sites/default/files/media-youtube" are (supposed to be) the thumbnails as pulled directly from youtube--before they're processed by Styles.
The thumbnails in "sites/default/files/styles/thumbnail/public/media-youtube" are the thumbnails after they've been processed by Image Styles.
To All:
The styles URI generated looks to be incorrect:
"sites/default/files/styles/thumbnail/public/media-youtube"
The access scheme (Public|Private) shouldn't be a folder within Image Styles.
If styles doesn't support, or is handling private URI's incorrecly this explains why the folder is generated, and why we can't access them in a Private context. (Considering the Private filesystem requires its own storage directory).
Comment #15
adamwhite commentedSubscribe
Comment #16
artatum commentedHello
Same issue : thumbnails ok on one hoster, not on another. I checked the logs, and first one is :
"Warning: simplexml_load_file() [function.simplexml-load-file]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in MediaInternetYouTubeHandler->getMRSS() (line 72 of /home/thewcul9/public_html/ng8/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc)."
If it can help...
Comment #17
artatum commentedThis is the response of AN hosting, the great, after sending them the message above:
"Dear a.
Looking at the custom php.ini in the /home/tttttt/public_html directory I found that the allow_url_fopen was set to off. I turned this to on and now see the thumbnail of the video. Please validate that this is now functioning properly for you now."
And the guy is right : my thumbnail are now created!
Check your php.ini maybe it'll help.
Comment #18
adamwhite commented@artatum that did change the behavior I'm seeing as Drupal's now displaying an error message. Hmm.
Warning: filesize(): stat failed for youtube://v/xxxxxxxxxx in file_save() (line 573 of /var/www/html/xxxxx/includes/file.inc).
Comment #19
Toxid commented@artatum, Thanks, it fixed my problems as well!
Comment #20
kifuzzy commented@artatum
me too. #16 solves it - after having a look to sys-log of drupal i found the message
you are my hero today :)
Comment #21
artatum commentedIt's good to be the king... (of the day ;-)
Comment #22
Toxid commentedBTW I spoke to a guy at my webhost the other day about allow_url_fopen, and he said that to avoid to have to set it to on, you could do this:
I don't know if this is helpful, perhaps there's drawbacks in this method that I'm not aware of, but since many people are having this problem it might be a better solution to have this in the module.
Comment #23
ddanier commentedsubscribing
I would very much favor a solution were allow_url_fopen may stay off for media_youtube to work. Isn't there a drupal-core-function for loading URLs (something like curlGet above)?
Comment #24
carn1x commentedI have allow_url_fopen enabled but still not getting any preview images. Also no error seems to be getting generated in my PHP error log.
EDIT: Moron alert, file permissions issue here :3. Maybe the module could provide an alert in status report if it can't write to public://media-youtube ?
Comment #25
gsquirrelI am also keen on getting this working without having to turn on allow_url_fopen
What about using 'drupal_http_request()' instead?
Comment #26
shane birley commentedI installed the latest dev and it is working a bit better. Not all formats are working but looking not too bad.
Comment #27
User11gtf commentedHello,
I have the same problem, thumbails are empy. This is the error log:
Warning: filesize() [function.filesize]: stat failed for youtube://v/xy_nKpZLo-0 en file_save() (línea 573 de /homepages/29/d292176751/htdocs/des/includes/file.inc).
#18 Have the same problem.
Active allow_url_fopen not solve the problem.
Any ideas?
Comment #28
cwithout commentedIf you look at the documentation for allow_url_fopen, it says.
"This option enables the URL-aware fopen wrappers that enable accessing URL object like files."
In includes/MediaYouTubeStreamWrapper.inc, line 34 uses the function copy($source, $dest). In the documentation for copy(), it states "Both source and dest may now be URLs if the "fopen wrappers" have been enabled."
That is, the use of copy() is what necessitates allow_url_fopen.
Here is a patch that uses drupal_http_request, which should be compatible with all installs, since it's part of the Drupal API.
If it turns out that some installations need to use copy() for some reason, we could always use copy() as a fallback. I've attached a patch that has code for that as well, but I don't think it'll be necessary.
So it'd be great if both people who have this issue and people who don't could try the media_youtube-empty-thumbnails-1180386.patch.
If it happens that it was working for you originally, but doesn't with the patch, try media_youtube-empty-thumbnails-1180386-alt.patch. (If it works, the "alt" patch is not needed.)
Comment #29
cwithout commentedComment #30
cwithout commentedI just saw from comment #16, there's another place that needs corrected too. Here's a patch which addresses the error in #16. I haven't seen this error in what I'm doing, so I can't verify, but it should eliminate it without needing to turn on allow_url_fopen.
The changes for the patch in #28 aren't included in this patch. It might be easier for troubleshooting to keep them separate.
So please install both the patch in #28 (media_youtube-empty-thumbnails-1180386.patch) and this patch (media_youtube-empty-thumbnails-1180386-16.patch).
(Again, only install media_youtube-empty-thumbnails-1180386-alt.patch from #28 if the first patch breaks the thumbnails when they used to be working.)
Comment #31
nathanjo commentedI tried using #28 media_youtube-empty-thumbnails-1180386-alt.patch and it works.
Comment #32
quironI also have the same problem and #28 media_youtube-empty-thumbnails-1180386-alt.patch works for me too, nice work, thanks
Comment #33
Ghelici commentedPatch #28 worked for me.
I have allow_url_fopen disabled, is that why youtube content names are generated from youtube url not from the video title
I found this patch Set $file->filename as video title but it only effected the video content.
When a new video content is submited a log is created when the thumbnail preview shows up;
Warning: filesize() [function.filesize]: stat failed for youtube://v/x-xxxxxxxxx in file_save() (line 573 of includes/file.inc).
Comment #34
pkchoo commentedHave these patches been incorporated into the latest beta (7.x-1.0-beta2) and dev (7.x-1.x-dev) releases, updated in the last week?
Thank you,
Joe
Comment #35
cwithout commented@pkchoo Looking at latest dev, the #28, #30 patches haven't been included. And the latest version adds more dependencies on allow_url_fopen being on by using get_headers().
@DevilEye - The name issue seems like discussion for a separate issue since this one is only about empty thumbnails. You might want to ask about it in #1368714: Set $file->filename as video title.
That warning message is from the save() method of MediaInternetYouTubeHandler when it calls file_save in core's file.inc.
I'm not sure what the affects of changing $file->uri to the local path would be. Since there's been no attention to this issue and additional dependencies on allow_url_fopen have been added, I'm not going to do any more work on this. It seems like the direction of the module is to require allow_url_fopen.
If the maintainers want to remove that dependency, please let me know and I'll look into it. If not, I would suggest adding the information that that configuration is required to the readme and/or project page.
Comment #36
Ghelici commentedhttp_request alternative is very welcome
Appreciated your support Cristinawithout
Comment #37
megatron777 commentedHey,
with the current script + patches, the thumbnails are being stored on the server,
but the youtube script doesnt seem to pick the right directory - I get this (within the gallery elements):
http://homepage.com/sites/default/files/styles/media_gallery_thumbnail/public/media-youtube/thevideothumbnail.jpgWhen I try to manipulate the local_path / dirname string and just hardcode the url it still adds up this:
http://styles/media_gallery_thumbnail/http/homepage.com/content/sites/default/files/media-youtube/thevideothumbnail.jpgAny ideas? Thanks in advance!
Comment #38
Taxoman commentedComment #39
cwithout commentedI'm somewhat encouraged by the fact that Dave Reid took out the get_headers() function and replaced it with drupal_http_request() in #1480556: Use drupal_http_request() instead of get_headers() in MeidaInternetYouTubeHandler::valid_id(). So these patches once again work to correct the issue. With some attention being paid to something similar, I'm hopeful that the efforts in this issue won't be wasted.
@DevilEye - Regarding the filesize() warning you were getting in #33, the file_save() function is no longer in MediaInternetYouTubeHandler.inc. Would you be able to test against the current dev and see if you still get the warning?
@megatron777 - That seems to me to be the behavior of the module with or without the patches (enabling allow_url_fopen without the patches) . I don't quite understand the problem, because that seems like the correct path to a thumbnail to me. You may want to open a separate issue for that.
Comment #40
steinmb commentedRerolling #30 against latest dev.
Comment #41
steinmb commentedCrossposting against media_vimeo #1504050: Use drupal_http_request() instead of of copy() and simplexml_load_file(), or else Media:Vimeo thumbnails may be empty that I created to make sure we also fix it there.
Comment #42
drewish commentedComing to this from the vimeo cross post. I feel like it might be better to throw exceptions instead of returning an empty element... Fail loudly rather than silently.
Comment #43
Ghelici commentedcristinawithout, it is still the same with the dev. release; I believe that I will have to enable fopen to use media module smoothly.
Comment #44
steinmb commented@DevilEye you need to test with patch #40 applied. Does not get committed until it have been tested and reviewed.
Comment #45
Ghelici commentedsteinmb, still filesize() warning using the #40 patch and latest dev
Comment #46
miahon commented@steinmb, I tested patch #40 with latest dev and also get that filesize() [function.filesize]: stat failed warning. Fopen function is disabled and I am using Media module version 7.x-1.0-rc3.
Comment #47
steinmb commentedMy guess is that your code is not failing on
getMRSS()but ingetOEmbed(). Agreeing with @drewish (#42), that we should try and return more gruesome error messages to flush out these kind of errors, instead of silently failing and returning empty objects. This throws errors and dump out the http return code, what error are you getting on your servers?Comment #48
wjaspers commentedYou have tabs in your code.
These need to be converted to two spaces per tab.
Code looks ok, although I haven't tested it.
Comment #49
steinmb commenteddoh! Just fired up Sublime text 2 to test it out, forgot to check the tab setting.
Comment #50
steinmb commentedLet's see if I got the settings in Sublime Text right this time. Rerolling with spaces instead of tabs (I hope).
Comment #51
steinmb commentedAnd, let's test and debug.
Comment #52
tomecruzz commentedThanx cristinawithout
==> patch #28 good
thanx god AllaH
______________
la ilaha illa allah mohamed rassol allah = There is no god but God, and Muhammad is the messenger of God
Comment #53
drupalninja99 commentedAre we sure we're patching the right thing? I figured out that many hosts disable fopen for remote urls as a security precaution. And so its a problem that the media and youtube modules use the copy() function with a remote source. If we used curl instead that would work for most hosts.
Something like the following or if you can do the same thing with drupal_http_request() then use that.
Comment #54
drupalninja99 commentedok I see we already have a good patch it appears with drupal_http_request: http://drupal.org/files/media_youtube-empty-thumbnails-1180386-alt.patch
That I think will work well.
Comment #55
ckngReroll #50 for latest dev.
Comment #56
AFFLemos commentedHi guys
Everything was ok but after upgrading to latest drupal version, my last 20 video thumbnails went blank but not all the previous ones.
But when i click on a thumbnail a error appears.
I've checked the php.ini file but the allow_url_fopen was already on.
I've installed all patches but the error maintains and it's the following:
Fatal error: Call to a member function getLocalThumbnailPath() on a non-object in /home/topgoals/public_html/sites/all/modules/media_youtube/includes/media_youtube.formatters.inc on line 150
I don't know any php by the way :)
What can it be?
Cheers
Comment #57
ckngReroll the complete patch based on #28 and #50 for dev.
Comment #58
mrfelton commentedPatch in #55 resolved for us.
Comment #59
arturs.smirnovs commentedPatches #28 and #30 resolved problem. Thanks!
Comment #60
mrfelton commentedWhist the path in #55 has resolved the problem in most cases, in some cases, I get the following warning and no thumbnail:
Comment #61
johnpitcairn commentedPatch at #57 works for me. Not seeing the issue noted in #60 (yet).
Comment #62
ckng@mrfelton
try #57
Comment #63
wjaspers commentedYou do not need an explicit "return;".
When an Exception is thrown, the function will automatically exit and stop processing.
$entry = new SimpleXMLElement();will never run.I'm not sure I understand why this is called if we get an HTTP error response.
Comment #64
kihap commented#57 worked for me. Thank you!
Comment #65
rovoIf I enter the name of the YouTube user in the Media browser search field, the error goes away.
Comment #66
drupalerocant commented#57 worked for me too. Thank you!
Comment #67
olarin commentedAlso had success with #57. Would like to see this patch added soon, with or without addressing #63.
Comment #68
crimsondryad commented#57 worked for us.
Comment #69
RobW commentedGoing to give this issue some attention and testing soon. Looks like #57 can be applied to 1.x -- for those who spent some time in this issue already, is this something that can be fixed in the same way on 2.x as well?
Comment #70
RobW commented#57 committed to 2.x-dev, with the
returnremoved as suggested in #63. A big thanks to everyone who worked on this.http://drupalcode.org/project/media_youtube.git/commit/6ded54e.