I’m mentioning this issue here just in case somebody else runs into the same problem. I’ve spent a few hours trying to track down the context that fire up these notices.

For an entityform with a file field, if that file field is displayed in the email display mode with “Generic file” format or “Table of files” format, the following notices will show up after form submission. No other entityforms settings influence this but the email display mode.

• Notice: Undefined property: stdClass::$uri in theme_file_link() (line 727 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in theme_file_icon() (line 765 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 809 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in file_icon_map() (line 852 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 824 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 824 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 824 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 824 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filemime in theme_file_link() (line 734 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filesize in theme_file_link() (line 734 of ...\public\modules\file\file.module).
• Notice: Undefined property: stdClass::$filename in theme_file_link() (line 740 of ...\public\modules\file\file.module).
• Notice: Undefined index: filesize in theme_file_formatter_table() (line 1011 of ...\public\modules\file\file.field.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johndp’s picture

any fix for this? ideally, we would like to display a link to download an uploaded file in the notification email.

drhey’s picture

FWIW, I was getting similar errors upon submission of an entityform (with a file upload field). However, when I removed a specific node submission rule that I crafted, the error message went away. The error message wasn't verbatim to the one posted here, but a google search of the syntax I was seeing led me here. So, I figured I'd contribute what little information I've gathered thus far. HTH!

CodigoVision’s picture

I'm getting the same errors. Anyone find a fix?

salvis’s picture

Project: Entityform » Drupal core
Version: 7.x-1.0 » 7.36
Component: Entityform Notifications » file.module
Priority: Minor » Normal

I see the same thing when I upload a .pdf file into a File field in a new comment and then preview the comment.

Entityform is not on that site.

DrCord’s picture

I also am getting this problem and am not using entity_form

DrCord’s picture

Worth noting: this only happens for comments, not nodes themselves. So for example on a forum topic preview works fine, but on the comments to it preview has this exact problem.

DrCord’s picture

I added this code to the function `theme_file_link`

if(!isset($variables['file']->uri)){
    $file = file_load($variables['file']->fid);
}

after

$file = $variables['file'];

and before:

$icon_directory = $variables['icon_directory'];

If anyone else will benefit I can put a patch up.

salvis’s picture

Version: 7.36 » 7.x-dev

Thanks for looking into it.

Having a patch against HEAD would be a first step towards getting a fix.

Also, knowing whether the issue is still present in D8 would define the scope.

cockers’s picture

I found this from a websearch and just wanted to let you know that this also happens when uploading via an editable field in a view.

All I needed to do to remove the error messages was to change the display setting to display URL.

salvis’s picture

Status: Active » Needs work

The theme_file_link() function expects to get

* - file: A file object to which the link will be created.

It's the caller's fault if they don't pass a fully populated file object. #7 may fix the symptoms, but it needs to be fixed at the calling site.

dhruveshdtripathi’s picture

I faced the same error. And my mistake was, I deleted the file from /admin/content/file but didn't delete the node with which the file was attached. Deleting the node solves the error.

Michelle’s picture

Status: Needs work » Needs review
FileSize
707 bytes

I agree with #10 that it should be fixed upstream but that's not always possible. In my case, it seems to be that Views isn't recognizing the file field has nothing in it so it's sending an empty file object to be rendered. This may not be the best way to fix it and likely won't ever be committed but it at least prevents the logs from filling up with notices.

This patch is a variation on the code in #7. In my case, I have a totally empty file object so my original code just bailed. Seeing #7, I added in an attempt to load it for folks that have the fid but not the rest.

poker10’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks for reporting this. I was able to simulate the problem with steps from the comment #4, therefore it seems to be a Drupal core problem (or at least a part of it is). I think that the patch #12 is not the best solution, as it will only mask the problem on the caller side (Drupal core should not babysit broken code).

But I think we can at least try to fix the problem with comment preview (see #4) and then see if the notices will be still there when using the entity_form and mail display mode.

Anyway, we would need a test here.

poker10’s picture

For the comment preview, it should be sufficient to add a _field_invoke_multiple(), as it is mentioned here: #1678686-26: Notice: Undefined index: uri in image_field_formatter_view(). Therefore I am not sure if the rest of the issue is a core problem instead of the entity_form? Probably it can be moved back to entity_form queue?