Notices output:
* Notice: Undefined index: file in media_field_formatter_view() (line 152 of /Library/WebServer/Documents/drupal7/modules/media/media.fields.inc).
* Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 781 of /Library/WebServer/Documents/drupal7/modules/file/file.module).
* Notice: Undefined property: stdClass::$filemime in file_icon_map() (line 823 of /Library/WebServer/Documents/drupal7/modules/file/file.module).
* Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 796 of /Library/WebServer/Documents/drupal7/modules/file/file.module).
* Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 796 of /Library/WebServer/Documents/drupal7/modules/file/file.module).
* Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 796 of /Library/WebServer/Documents/drupal7/modules/file/file.module).
* Notice: Undefined property: stdClass::$filemime in file_icon_path() (line 796 of /Library/WebServer/Documents/drupal7/modules/file/file.module).

Steps to reproduce:
Fresh install of Drupal 7.
Install Media and Styles modules.
Enable Media module - automatic enabling of other modules used.
Create a new content type with the following selections
add a Multimedia Asset field
Allowed media types: all
Allowed URI schemes: public (this doesn't seem to matter)
Unlimited number of values.
Create a new node with the new content type.
Upload a single Powerpoint presentation.
Save new node.
View node, see notices above.

It appears that no check is made to be certain filemime type is set. Perhaps that check should occur, and return the default if it's not?

Comments

droplet’s picture

Title: Several notices when displaying node; file_icon_path » Undefined index: file_icon_path
Version: 7.0 » 8.x-dev
Component: file system » file.module
Assigned: Unassigned » droplet
Status: Active » Needs review

bug fix & a little optimization

if no $file->filemime defined, skip to last fallback directly.

droplet’s picture

StatusFileSize
new1.94 KB

forgot attach it

droplet’s picture

StatusFileSize
new2.1 KB

a bit better

droplet’s picture

StatusFileSize
new2.1 KB

sorry, too much patch, fix tab problem

droplet’s picture

#4: file_icon_path.patch queued for re-testing.

drzraf’s picture

I was once able to get these notices in D7, at /admin/config, 5 or 6 occurrences at a time.
but I'm not yet able to reproduce it consistently.

dman’s picture

StatusFileSize
new2.12 KB

The patch does look like it would fix the described problem. However, seems like it was rolled from the wrong dir (or is very outdated - pre the core folder move)

The steps required to replicate this edge case in a simpletest would be really hard to automate.

My review: yes this is an accurate improvement. Will not introduce any problems. But we'll not be able to prove it works.

Here's a re-roll against current code.

drzraf’s picture

StatusFileSize
new3.03 KB

Attached is a stack trace from D7; patch #4 did not fixed it.
It appears in <front> in teaser mode, the first node has 1 pdf file attached.
The notice appears 3 times before the /icons/default/application-octet-stream.png img is display.
(= lines 808, 851 then 823 of file.module)

Please note that in the attached stack trace, the argument n°1 of the function call 24 (Array, 46 elements) is the valid file referenced by the node (though not expanded in the posted trace).

I'm using media, "Format" is "Rendered File", View mode: "preview".
The "preview" view mode has not been specified in any fashion in the file types (neither Application nor Others (don't know which one pdf belongs to)), so it should be in its "install state".

in case it helps and relates to this issue.

kscheirer’s picture

#7: file_icon_path_1.patch queued for re-testing.

kscheirer’s picture

Retesting against latest HEAD since it has been over a year.

Status: Needs review » Needs work

The last submitted patch, file_icon_path_1.patch, failed testing.

droplet’s picture

Assigned: droplet » Unassigned

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Version: 8.9.x-dev » 7.x-dev
Issue tags: +Bug Smash Initiative

file_icon_path was removed in #2236855: Use CSS for file icons in file fields on Drupal 8.0.x. This is outdated for Drupal 8. However, it is still relevant for Drupal 7.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.