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.

CommentFileSizeAuthor
#2 1533576-filesize-2.patch941 bytesbc
#1 1533576-filesize.patch445 bytesbc
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bc’s picture

FileSize
445 bytes

Could we use the File interface's filesize object property instead? Patch attached.

bc’s picture

FileSize
941 bytes

found another filesize(), new patch attached

gmclelland’s picture

Thanks @bc, I tested the patch in #2 and it worked as advertised. I no longer receive the errors.

mareks’s picture

Thanks, Worked for me too!

Simon Georges’s picture

Status: Active » Needs review

Changing status, as there is a patch.

TechNikh’s picture

bookmarking..

lawik’s picture

Priority: Normal » Major
Status: Needs review » Needs work

Patch 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.

lawik’s picture

Status: Needs work » Reviewed & tested by the community

Hmm, 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.

OnkelTem’s picture

When the patch will be commited?

Dave Reid’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

sp_key’s picture

Hi,

I have the same issue when linking to flickr images.
Any suggestions?