Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've found this issue with the updated drupal sites of us, when the theme_file_icon function was called without specified the alt property, it throws notice - as i see the icon_directory can throw the same problem.
I'm attaching my solution as a patch here.
The issue where it was changing: #2163209: Add alternate text to file icon
Comment | File | Size | Author |
---|---|---|---|
make-alt-and-icon_directory-properties-really-optionals_1.patch | 910 bytes | tatarbj | |
Comments
Comment #3
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI can't reproduce any problem here -
theme('file_icon', array('file' => file_load(1)))
works fine for me with no PHP notices (assuming there's an actual file on the site with ID = 1).That's because the default values of these variables are defined in hook_theme() (see http://cgit.drupalcode.org/drupal/commit/?id=830fdea).
Did you forget to run update.php (or at least clear caches) after updating your site to the latest Drupal core version?
Comment #4
tatarbjHi @David_Rothstein,
i've checked our cluster and actually because we still using 7.39 with only the security updates from the last two versions of drupal (don't ask why...), the changes are not applied there, maybe it is the reason why i realised this issue on our systems. The message was this: Notice: Undefined index: alt in theme_file_icon() (line 800 of /.../modules/file/file.module). This message was pointing to the first usage of $variables['alt'] that's why when i've checked the code i thought it can be the solution, but you're right because it is already defined in hook_theme() it shouldn't be an issue.
Comment #5
pfrenssen@tatarbj thanks for the clarification!