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/

Also related, if I use @becw "Automatically open the file edit modal after uploading a file" patch 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/

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.

#2 1533576-filesize-2.patch941 bytesbc
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View
#1 1533576-filesize.patch445 bytesbc
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


bc’s picture

445 bytes
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View

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

bc’s picture

941 bytes
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View

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


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


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