This bug affects sites which have set their default file scheme to something other than public://, but it subtly screws them up in a really hard to notice manner. On line 46 of MediaYouTubeStreamWrapper.inc, a hardcoded public:// scheme is used for the path to the locally saved video thumbnail image. This needs to be the Drupal API function file_default_scheme() instead, and I've included a patch for it.
I noticed this problem because my site uses the AmazonS3 module to replace the default file scheme with s3://. This is because we host our site in a load-balanced, multi-server cloud, so we can't let uploaded files sit on one of the server's local file systems, since they'd be inaccessible to the other servers. Oddly enough, this bug doesn't actually break our site's YouTube thumbnails, because of the way it checks for the existence of the thumbnail before serving it. Each time a server manages a request for the thumbnail the first time, it checks it's own local filesystem for the image, discovers that it's not there, and creates it anew. This is an waste of processing time and disk space, which is why I needed to fix the bug. And it's entirely possible that this happy accident that's saving our site won't save a site that's using a different non-default file scheme.
This bug also appears to effect every module that derives a StreamWrapper class from MediaReadOnlyStreamWrapper. I've written a patch for Media: Vimeo as well (#1836942: Thumbnail images are improperly stored), but I don't know which other modules derive from MediaReadOnlyStreamWrapper.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | media_youtube-revert_file_scheme_change-1836926-3.patch | 852 bytes | coredumperror |
| media_youtube_thumbnail_file_scheme_fix.patch | 736 bytes | coredumperror |
Comments
Comment #1
RobW commentedGreat catch. A very simple change, so reviewed and committed: http://drupalcode.org/project/media_youtube.git/commit/5aa2a86.
Comment #3
coredumperror commentedFor some reason this change got reverted, with a comment saying why hard-coding "public://" is correct. I imagine that whoever made that change probably forgot why
file_default_scheme()was needed (for remote file systems).Here's a new patch to revert this incorrect change.
Comment #4
devin carlson commentedThis was changed back in #1946002: Media Youtube doesn't work with the private filesystem probably because there were a number of issues with private files at the time (#1420812: Files from private stream cannot be downloaded, #2106717: file_entity_access broken by file_view_page for private files).
I agree that this should not be hard-coded and will make it difficult/impossible to use Media: YouTube with remote file systems.
Committed #3 to Media: YouTube 7.x-2.x.
Comment #5
coredumperror commentedThank you!
Comment #5.0
coredumperror commentedAdded link to equivalent Vimeo issue