Closed (outdated)
Project:
Drupal core
Version:
6.x-dev
Component:
theme system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Sep 2009 at 01:08 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Bevan commentedtheme() changed considerably in Drupal 7. I haven't tested, but those changes don't seem to have fixed this bug.
Comment #3
Bevan commentedThat patch wasn't supposed to pass because it's for drupal 6 (I should have reverted ticket status to "needs work" to prevent testing), but the file didn't even get onto the d.o file system for some reason
Comment #4
Bevan commentedThis fix means that theme functions and theme function overrides can not (and should not) define default values for arguments in their signatures. This conflicts with common practice in Drupal 6 and therefore isn't recommended there. It might be a good solution for Drupal 7 though.
For example, the
item_listtheme hook is defined in the theme registry indrupal_common_theme(). as;It's theme function has the signature;
theme_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = array())A theme called custom can override it by defining a function called
custom_item_list(), perhaps with a different signature that has different default values for it's arguments, such ascustom_item_list($items = array(), $title = NULL, $type = 'ol', $attributes = array('class' => 'item-list'))Without this patch the defaults of the overridden function (
oland the css classitem-list) are respected whentheme('item_list')is called without those arguments. This is an (undocumented?) feature of Drupal. However the default values in the hook definition in the theme registry are never used (for function theme hooks – they are used for templatetpl.phptheme hooks).With this patch, the default argument values in the signature of the overriding function (or the original,
theme_item_list()) are never used, thus breaking the undocumented feature and changing how the theme API functions, albeit in order to adhere to documentation.With or without this patch there are default values for arguments somewhere that are never used, which is redundant and confusing. The possible solutions are to either;
Since adhering to documentation requires a change to the theme API it will have significant ramifications for contrib and is not recommended for drupal 6, but is probably the best solution for Drupal 7.
The first option is a documentation bug fix and is recommended for Drupal 6.
Pending consensus we should fork this issue into the separate solutions and patches for each of Drupal 6 and 7.
Some grepping (
grep -r "function theme_.\+\(.\+=.\+\)" .) reveals 29 theme function signatures in drupal HEAD that define default values for arguments. 20 of those are not NULL (grep -r "function theme_.\+\(.\+=.\+\)" . | grep -v "function theme_.\+\(.\+= NULL.\+\)").In Drupal 6 these numbers are 28 and 17, but that only counts drupal 6 core, not contrib.
Comment #5
Bevan commentedThere is no code to review, but the suggestion solution does need review.
Comment #7
Bevan commentedwtf!
Comment #8
Bevan commentedOh, the patch was actually there, the URL's are borked though (It's here). This might be because of #310139: drupal_query_string_encode() should not call drupal_urlencode() which was recently released in 6.14. This one has no space chars so should work.
Comment #9
effulgentsia commentedThis is fixed in D7. Changing to D6 issue.
Comment #10
MantasK commented#3: 579776 drupal 6 theme arguments.patch queued for re-testing.
Comment #12
Bevan commentedThat was a CVS patch. It probably needs to be a git patch now.