Using the latest dev of file_entity, when I save a node that has a filefield it will throw this error.
Warning: filesize(): stat failed for public://design2themein5.pdf in file_entity_image_dimensions() (line 160 of /home/quickstart/websites/updater.dev/profiles/cmf/modules/contrib/file_entity/file_entity.file.inc).
Also related, if I use @becw "Automatically open the file edit modal after uploading a file" patch http://drupal.org/node/1426730#comment-5766946 I get this error when I save the node.
Warning: filesize(): stat failed for temporary://dsc_0048.jpg in file_entity_image_dimensions() (line 160 of /home/quickstart/websites/updater.dev/profiles/cmf/modules/contrib/file_entity/file_entity.file.inc).
The file dsc_0048.jpg was uploaded
In this case I use the media selector and upload a file. The patch enables me to immediately edit the file that has fields attached. When I save I see the error. To fix this from happening, I can use this commit 0a16da6854f78244be5884cfc9f492deb326234b from Fri, 23 Mar 2012.
In both cases the node and file saves correctly.
Comment | File | Size | Author |
---|---|---|---|
#2 | 1533576-filesize-2.patch | 941 bytes | bc |
#1 | 1533576-filesize.patch | 445 bytes | bc |
Comments
Comment #1
bc CreditAttribution: bc commentedCould we use the File interface's filesize object property instead? Patch attached.
Comment #2
bc CreditAttribution: bc commentedfound another filesize(), new patch attached
Comment #3
gmclelland CreditAttribution: gmclelland commentedThanks @bc, I tested the patch in #2 and it worked as advertised. I no longer receive the errors.
Comment #4
mareks CreditAttribution: mareks commentedThanks, Worked for me too!
Comment #5
Simon Georges CreditAttribution: Simon Georges commentedChanging status, as there is a patch.
Comment #6
TechNikh CreditAttribution: TechNikh commentedbookmarking..
Comment #7
lawik CreditAttribution: lawik commentedPatch removes problem but doesn't do what was intended. Checking the filesize of the file is supposed to protect from PHP warnings.
The file object uses the Drupal default controller for entities, that means that the $file->filesize is loaded from the database, not checked against the file on disk or the remote YouTube clip or whatever your stream wrappers are getting you.
So if the file is gone or has been emptied you can still get a filesize from Drupal but the code in question hasn't protected you from the PHP warning as intended.
This patch might as well comment out the condition as far as I can see.
Comment #8
lawik CreditAttribution: lawik commentedHmm, checked the history of the original warning and it covers the specific case of uploading a 0-byte file (which would throw the warning). This is correctly checked by this code (worked fine with my empty PNG).
Marking as reviewed and tested.
Comment #9
OnkelTem CreditAttribution: OnkelTem commentedWhen the patch will be commited?
Comment #10
Dave ReidThanks I've committed this to File entity 7.x-2.x and Media 7.x-1.x.
http://drupalcode.org/project/file_entity.git/commit/e2da521
http://drupalcode.org/project/media.git/commit/d01000f
Comment #12
sp_key CreditAttribution: sp_key commentedHi,
I have the same issue when linking to flickr images.
Any suggestions?