Closed (works as designed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Dec 2010 at 20:15 UTC
Updated:
2 Apr 2014 at 18:55 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dave reidWhy is the attributes value required now?
Comment #2
jacineThis has to be a bug, no?
Comment #3
damien tournoud commentedattributes is definitely not required.
Comment #4
pillarsdotnet commentedFailure to provide at least an empty array() results in a PHP notice.
From the code:
That first line will result in an "Undefined index" notice.
Comment #5
pillarsdotnet commentedComment #6
dave reid@pillarsdotnet: Prove to me that doing theme('image', array('path' => 'pathtofile.png')); causes a problem and that the theme system fails to merge in the default attributes variable of an empty array?
Comment #7
pillarsdotnet commentedRun the attached code snippet in php. Mine produces the following output:
Comment #8
jacineI tested this a little, and I'm not seeing notices for theme_image(). However, I am seeing a similar problem with theme_html_tag() as far as defaults not merging properly, so maybe there is a problem here that only happens under certain circumstances? This is what I tested with.
Notice: Undefined index: #attributes in theme_html_tag() (line 1904 of /Users/jacine/Sites/drupal-7/includes/theme.inc).
Recoverable fatal error: Argument 1 passed to drupal_attributes() must be an array, null given, called in /Users/jacine/Sites/drupal-7/includes/theme.inc on line 1904 and defined in drupal_attributes() (line 2253 of /Users/jacine/Sites/drupal-7/includes/common.inc).
Comment #9
dave reid@pillarsdotnet: You are incorrectly using the theme system. You call theme functions using the literal theme() function. Use theme('image', ...) and not theme_image(...).
Comment #10
dave reid@Jacine: Because html_tag is defined as render element, do the errors go away if you use '#type' => 'html_tag' rather than '#theme' => 'html_tag'?
Comment #11
pillarsdotnet commented@Dave Reid: Either the theme_image() function has required parameters or it doesn't. Telling me that I shouldn't be using it at all is quite beside the point.
And I *am* getting "Undefined index" notices in my log, and in every case, a backtrace() shows them coming from a theme('image' that fails to include an attributes key.
I will produce a repeatable test case, starting with a clean minimal Drupal-7 install, shortly.
Comment #12
dave reidPlease read:
http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/6 - "All requests for theme hooks must go through this function."
http://techylinguist.com/code-snippet/drupal-6-theming-functions-images-... - "Where's the call to theme_image()? We NEVER call theme functions directly."
Comment #13
marcingy commentedThis is duplicate in effect of this issue http://drupal.org/node/1001990. This isn't a bug this someone missusing the api.
Comment #14
dave reidYes, if you can reproduce with latest 7.x-dev core with Standard or minimal install, and no contrib modules, that would be useful. Please also include what function/module calls theme('image') from your backtrace info.
Comment #15
jacine@davereid, Yep, the errors do go away with type. Sorry, my bad. I didn't realize that theme function only works for render elements. Separate issue though, I guess. :)
FYI, I also tried printing directly in a template file, with theme_image() and still I'm not seeing any notices.
Comment #16
pillarsdotnet commentedIf the function is for internal use only, it should say so.
Comment #17
marcingy commentedPlease read this thread http://drupal.org/node/1001990 - the function already links to http://api.drupal.org/api/drupal/modules--system--theme.api.php/group/th... which explains that it is internal only. There is nothing to fix here.
The api page even gives an example - http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_image/7
Therefore, this variable defaults to an empty string, but can be set to NULL for the attribute to be omitted. Usually, neither omission nor an empty string satisfies accessibility requirements, so it is strongly encouraged for code calling theme('image') to pass a meaningful value for this variable.
Comment #18
pillarsdotnet commented@marcingy -- Thanks for the education and links.
Comment #19
dp07Daniel commentedWhat it means for internal use? Do not have a solution?