Closed BerkeleyEdu closed 11 years ago
@BerkeleyEdu do you have allow_url_fopen
set to On
?
Yup.
http://m-qa.berkeley.edu/phpinfo.php
On 9/14/2012 7:59 AM, Eric Bollens wrote:
@BerkeleyEdu https://github.com/BerkeleyEdu do you have |allow_url_fopen| set to |On|?
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8563924.
Sara Leavitt, Electronic Communications Specialist UC Berkeley Office of Public Affairs 2200 Bancroft Way, Berkeley, CA 94720-4204 Phone: 510 643-6163 http://events.berkeley.edu http://www.berkeley.edu/mobile
I'm kind of at a loss as to what may be causing it, so let's do a couple debug things:
Remote_Image
class, can you get me the value of $image_url
right before if (ini_get('allow_url_fopen')) {
?gethostbyname()
on the value of $image_url
? Looks like disk_cache.class.php throws an exception in line 60 when permissions are set wrong on the var
directory, and that the image minifier is probably not catching that exception.
By the way, I did a sudo chown apache mwf/var
and now it works for UCSF. We had permissions set wrong. Oopsy.
Not sure how to debug this class. I've tried these at the spot before the fopen, but not seeing results:
//debug print gethostbyname($image_url) ; exit;
or
//debug return gethostbyname($image_url) ; exit;
Also, do I need to create "img" and "simplepie" directories within "/mwf/var/cache" ahead of time?
-Sara
On 9/17/2012 7:59 AM, Eric Bollens wrote:
I'm kind of at a loss as to what may be causing it, so let's do a couple debug things:
- In the |Remote_Image| class, can you get me the value of |$image_url| right before |if (ini_get('allow_url_fopen')) {|?
- Can you call |gethostbyname()| on the value of |$image_url|?
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8617571.
Sara Leavitt, Electronic Communications Specialist UC Berkeley Office of Public Affairs 2200 Bancroft Way, Berkeley, CA 94720-4204 Phone: 510 643-6163 http://events.berkeley.edu http://www.berkeley.edu/mobile
Try using this to log the output: http://php.net/manual/en/function.error-log.php
Because you're generating images, it's not very easy to do output through a print.
Sara, the fix for this is at https://github.com/ucla/mwf/commit/7160434fcc1957b669f5e9aeb19e0f37ba74d8c5. That will allow remote images to work with a cache that has permissions set too tight.
However, you should be able to fix this with the existing code by setting the permissions on your cache. Can you email me the output of running ls -ld mwf/var/cache
and ps -ef | grep httpd
so I can confirm there isn't something else weird going on here? Thanks.
Hi Rich,
Here is the permission info -- does it look correct?
-sh-3.2$ cd /var/www/html -sh-3.2$ ls mwf mwf.BACK -sh-3.2$ ls -ld mwf/var/cache drwxrw-r-- 4 apache webmaster 4096 Sep 13 12:27 mwf/var/cache -sh-3.2$ ps -ef | grep httpd root 3050 1 0 Sep01 ? 00:00:00 /usr/sbin/httpd saral 14594 14544 0 09:39 pts/0 00:00:00 grep httpd root 19934 3050 0 Sep16 ? 00:00:00 logger -t httpd-extended -p local3.info root 19935 3050 0 Sep16 ? 00:00:00 logger -t httpd-extended -p local3.info root 19936 3050 0 Sep16 ? 00:00:00 logger -t httpd-extended-ssl -p local3.info root 19937 3050 0 Sep16 ? 00:00:00 logger -t httpd-extended-ssl -p local3.info root 19938 3050 0 Sep16 ? 00:00:00 logger -t httpd-extended -p local3.info root 19939 3050 0 Sep16 ? 00:00:00 logger -t httpd-extended-ssl -p local3.info apache 19956 3050 0 Sep16 ? 00:00:13 /usr/sbin/httpd apache 19957 3050 0 Sep16 ? 00:00:12 /usr/sbin/httpd apache 19958 3050 0 Sep16 ? 00:00:13 /usr/sbin/httpd apache 19959 3050 0 Sep16 ? 00:00:12 /usr/sbin/httpd apache 19960 3050 0 Sep16 ? 00:00:12 /usr/sbin/httpd apache 19961 3050 0 Sep16 ? 00:00:12 /usr/sbin/httpd apache 19962 3050 0 Sep16 ? 00:00:12 /usr/sbin/httpd apache 19963 3050 0 Sep16 ? 00:00:12 /usr/sbin/httpd
What is the git command to extract your code fix?
Thanks, Sara
On 9/18/2012 5:53 AM, Trott wrote:
Sara, the fix for this is at ucla/mwf@7160434 </ucla/mwf/commit/7160434fcc1957b669f5e9aeb19e0f37ba74d8c5>. That will allow remote images to work with a cache that has permissions set too tight.
However, you should be able to fix this with the existing code by setting the permissions on your cache. Can you email me the output of running |ls -ld mwf/var/cache| and |ps -ef | grep httpd| so I can confirm there isn't something else weird going on here? Thanks.
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8653311.
Sara Leavitt, Electronic Communications Specialist UC Berkeley Office of Public Affairs 2200 Bancroft Way, Berkeley, CA 94720-4204 Phone: 510 643-6163 http://events.berkeley.edu http://www.berkeley.edu/mobile
Your permissions look correct to me. Can you run the ls -ld
command again but leave off the d
so it's just ls -l
?
To get the patch:
git fetch --all
git cherry-pick 7160434fcc1957b669f5e9aeb19e0f37ba74d8c5
-sh-3.2$ cd /var/www/html -sh-3.2$ ls -l mwf/var/cache total 0 ?--------- ? ? ? ? ? img ?--------- ? ? ? ? ? simplepie
Not sure what this means? -Sara
On 9/18/2012 2:48 PM, Trott wrote:
Your permissions look correct to me. Can you run the |ls -ld| command again but leave off the |d| so it's just |ls -l|?
To get the patch:
git fetch --all git cherry-pick 7160434fcc1957b669f5e9aeb19e0f37ba74d8c5 — Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8671962.
Sara Leavitt, Electronic Communications Specialist UC Berkeley Office of Public Affairs 2200 Bancroft Way, Berkeley, CA 94720-4204 Phone: 510 643-6163 http://events.berkeley.edu http://www.berkeley.edu/mobile
I have isolated where the image class fail with error messages. I receive the first error message but not the second.
Error:/var/www/html/mwf/var/cache/img/8164fa0349599a1ac260c1afd7fcfe0a
$path = $this->_cache ? $this->_cache->get_cache_path($this->get_cache_key()) : false;
error_log("Error:" . $path, 1,"saral@berkeley.edu");
if (($path === false) || (!file_exists($path))) {
error_log("here is an error 7", 1,"saral@berkeley.edu");
So that returns me to a question I had earlier about creating the img directory in the cache directory ahead of time. Should Iask the sysadm to do that? But still not sure what this means? Are those directories there or not?
-sh-3.2$ ls -l mwf/var/cache total 0 ?--------- ? ? ? ? ? img ?--------- ? ? ? ? ? simplepie
You should not create anything in the cache directory manually. The code will create directories that it needs. I don't know why there are all those question marks for those to directories, but I would delete them and see if they get recreated without problems.
The permissions are fixed in the cache directories and the remote_image.class.php function completes -- no longer getting stuck on the path====false statement. However, the images are still not displaying:
How do I know if this is working? $this->_image_gd = imagecreatefromjpeg($path);
You need to apply 7160434fcc1957b669f5e9aeb19e0f37ba74d8c5. (Alternatively, Eric, it's the pending pull request. Just slurp it into master and have Sara grab it from there.)
Merged it
Rich, Thanks, but I applied that update last week per your instructions:
-sh-3.2$ git cherry-pick 7160434fcc1957b669f5e9aeb19e0f37ba74d8c5
Must be something about my directory set up. Here are the permissions.
Does this look correct?
-sh-3.2$ pwd /var/www/html/mwf/var -sh-3.2$ ls -l total 16 drwxrwxr-- 4 apache webmaster 4096 Sep 13 12:27 cache -rwxrwxr-x 1 apache webmaster 198 Aug 10 10:36 README -sh-3.2$ ls -l cache total 16 drwxrwxr-- 2 apache webmaster 4096 Sep 24 15:40 img drwxrwxr-- 2 apache webmaster 4096 Sep 8 07:57 simplepie -sh-3.2$ ls -l cache/img total 24 -rw-rwxr-- 1 apache webmaster 1857 Sep 19 15:22 33ddbc76f9bebc08952910254c80b3c4 -rw-rwxr-- 1 apache webmaster 1409 Sep 25 19:15 8164fa0349599a1ac260c1afd7fcfe0a -rw-rwxr-- 1 apache webmaster 1465 Sep 25 18:55 d0a015375f8202aa67968d59b9aa2f69
On 9/25/12 7:14 PM, Trott wrote:
You need to apply 7160434 https://github.com/ucla/mwf/commit/7160434fcc1957b669f5e9aeb19e0f37ba74d8c5. (Alternatively, Eric, it's the pending pull request. Just slurp it into master and have Sara grab it from there.)
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8876824.
Definitely related to local vs. remote images:
Root relative URL for image displays:
Same Image with absolute URL produces error:
On 9/25/12 7:14 PM, Trott wrote:
You need to apply 7160434 https://github.com/ucla/mwf/commit/7160434fcc1957b669f5e9aeb19e0f37ba74d8c5. (Alternatively, Eric, it's the pending pull request. Just slurp it into master and have Sara grab it from there.)
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8876824.
When you run wc -l mwf/root/assets/lib/image.class.php
is the result 190 or 196?
-sh-3.2$ wc -l mwf/root/assets/lib/image.class.php 196 mwf/root/assets/lib/image.class.php
On 9/26/2012 6:55 PM, Trott wrote:
When you run |wc -l mwf/root/assets/lib/image.class.php| is the result 190 or 196?
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8916513.
Sara Leavitt, Electronic Communications Specialist UC Berkeley Office of Public Affairs 2200 Bancroft Way, Berkeley, CA 94720-4204 Phone: 510 643-6163 http://events.berkeley.edu http://www.berkeley.edu/mobile
Just to make sure, I completely replaced my image.class.php with the code from https://github.com/ucla/mwf/blob/master/root/assets/lib/image.class.php
Still getting error. Funny thing is that if I comment out the header line in img.php
//header("Content-type: " . $image->get_mimetype());
then I see binary data (not a blank) so I think the file is getting stored and retrieved from cache.
-Sara
On 9/26/2012 6:55 PM, Trott wrote:
When you run |wc -l mwf/root/assets/lib/image.class.php| is the result 190 or 196?
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8916513.
Sara Leavitt, Electronic Communications Specialist UC Berkeley Office of Public Affairs 2200 Bancroft Way, Berkeley, CA 94720-4204 Phone: 510 643-6163 http://events.berkeley.edu http://www.berkeley.edu/mobile
I saved the binary code from the remote and local versions of the same file to my desktop.
The local version opens fine in PhotoShop: http://m-qa.berkeley.edu/assets/min/img.php?img=/assets/img/berkeley-mobile-logo.png
but remote version: http://m-qa.berkeley.edu/assets/min/img.php?img=http://m-qa.berkeley.edu/assets/img/berkeley-mobile-logo.png
produces the error: "Could not complete this operation. The internal file signature is incorrect"
Sara Leavitt, Electronic Communications Specialist UC Berkeley Office of Public Affairs 2200 Bancroft Way, Berkeley, CA 94720-4204 Phone: 510 643-6163 http://events.berkeley.edu http://www.berkeley.edu/mobile
Looks like you left the header()
line commented out. Could you put it back? Also, yeah, try rm mwf/var/cache/img/*
just to make sure that it isn't a corrupted cache file.
The cache file in img that should be created will be called 5cfee1e8dd1df260e85dd064fab0b626
. If removing it and trying again doesn't solve the problem, what is the output if you run file mwf/var/cache/img/5cfee1e8dd1df260e85dd064fab0b626
and wc -c mwf/var/cache/img/5cfee1e8dd1df260e85dd064fab0b626
?
Looks like it's generating corrupt files straight up on the remote URLs. I added max_height
values to the URL so that I could be reasonably sure I wasn't reading from your cache but I'm still getting corrupted results.
When I do a vanilla checkout of the master branch, I don't have any problems with the same exact files and URL params.
Try this: rm mwf/var/cache/img/*
and then watch your Apache error log while you try to pull up a remote image. Maybe there's an error or warning that will give us a clue as to what's going on here.
Fixed!
I replaced remote_image.class.php with the version in git and the images are now loading. My version looked the same, but it must have gotten corrupted when I was debugging the cache directory permission problems.
Thanks for all your help!
-Sara
On 9/27/12 10:41 PM, Trott wrote:
Looks like it's generating corrupt files straight up on the remote URLs. I added |max_height| values to the URL so that I could be reasonably sure I wasn't reading from your cache but I'm still getting corrupted results.
When I do a vanilla checkout of the master branch, I don't have any problems with the same exact files and URL params.
Try this: |rm mwf/var/cache/img/*| and then watch your Apache error log while you try to pull up a remote image. Maybe there's an error or warning that will give us a clue as to what's going on here.
— Reply to this email directly or view it on GitHub https://github.com/ucla/mwf/issues/168#issuecomment-8965173.
The image compressor in my qa installation of MWF 1.3 installation:
is throwing these errors
Sep 13 12:27:14 as-mobile-qa httpd[3288]: [error] [client 169.229.206.54] PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/mwf/root/assets/lib/image/remote_image.class.php on line 57 Sep 13 12:27:14 as-mobile-qa httpd[3288]: [error] [client 169.229.206.54] PHP Warning: file_get_contents(http://events.berkeley.edu'.): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/mwf/root/assets/lib/image/remote_image.class.php on line 57 Sep 13 12:27:14 as-mobile-qa httpd[3288]: [error] [client 169.229.206.54] PHP Notice: getimagesize(): Read error! in /var/www/html/mwf/root/assets/lib/image.class.php on line 179 Sep 13 12:27:14 as-mobile-qa httpd[3288]: [error] [client 169.229.206.54] PHP Notice: exif_imagetype(): Read error! in /var/www/html/mwf/root/assets/lib/image/remote_image.class.php on line 98
Also does NOT work using UCSF's installation http://m.ucsf.edu/assets/min/img.php?img=http://events.berkeley.edu/images/user_uploads/0_desert_medium.jpg&max_height=60&max_width=60
But works OK with UCLA: http://m.ucla.edu/assets/min/img.php?img=http://events.berkeley.edu/images/user_uploads/0_desert_medium.jpg&max_height=60&max_width=60
-Sara