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.
This shows up at admin/structure/types/manage/article/display. 'no_striping'=TRUE
is supposed to prevent even/odd classes from being added to rows, which it is, but it's also getting lumped in as if it were a regular attribute:
<tr class="region-message region-visible-message region-populated" no_striping="1"><td colspan="7">No field is displayed.</td> </tr>
The problem is in theme.inc. In d6, $row only contained 'data' and attributes, but in d7 'no_striping' may be in $row as well:
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
}
else {
$attributes[$key] = $value;
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#20 | 935066-20.patch | 1.19 KB | fietserwin |
#15 | remove-no-striping-in-theme_table-935066-15.patch | 1.71 KB | BarisW |
#12 | 935066-10.patch | 1.17 KB | fietserwin |
#1 | 935066_no_striping_1.patch | 385 bytes | markabur |
Comments
Comment #1
markabur CreditAttribution: markabur commentedAttached patch checks for no_striping before adding the key/value as an attribute.
Comment #2
markabur CreditAttribution: markabur commentedComment #3
markabur CreditAttribution: markabur commentedComment #4
adamdicarlo CreditAttribution: adamdicarlo commentedPatch works fine for me.
Comment #5
fietserwinPatch works fine for me as well.
Comment #6
Dries CreditAttribution: Dries commentedThe better solution (for Drupal 8) is probably to separate data/content from settings. Lumping things together in one array is a bad idea -- this patch is a bit of a hack. Shall we fix this in Drupal 8 first?
Comment #7
fietserwinI can agree with separating different concerns. However I disagree about changing this in D8 first. This patch is about solving, not introducing, an error due to not separating stuff. The changes for D8 would introduce an API change and thus won't be ported back to D7. I would suggest fixing the error in D7 using this patch, and creating a new feature request/task for D8.
Aside: #616240: Make Field UI screens extensible from contrib - part II introduced the no_striping option. Scanning through that one, I can understand that this slipped through.
Comment #8
markabur CreditAttribution: markabur commentedThe whole no_striping thing is kind of a hack, so I can see rethinking that somehow. Currently in d7 theme_table() is unusable for anyone who needs valid xhtml but doesn't want even/odd classes. What this means for d8 I have no idea.
Comment #9
catchPer the discussion at #1050616: Figure out backport workflow from Drupal 8 to Drupal 7, current consensus is that quick fixes get applied to both 7.x and 8.x, and then a new 8.x issue is opened for the proper fix. The idea is to prevent Drupal 7 patches being stalled on API changes in 8.x, while also ensuring that 8.x isn't released with regressions compared to Drupal 7. That issue is still open but it's the best we have for a strategy for dealing with this.
Comment #10
claar CreditAttribution: claar commented#1: 935066_no_striping_1.patch queued for re-testing.
Comment #11
fietserwin[comment removed: same comment posted twice, next one has the patch attached]
Comment #12
fietserwinPutting several things together in 1 array is quite normal (at least in an untyped language like PHP). Examples are:
- Form arrays in Drupal: childs and processing data/instructions.
- Render elements in Zend framework: properties (server side) and attributes (client side) are all put in the same array (at the same level).
- Data, properties ('header') and attributes in table cells in Drupal!
This patch is more in line with how function _theme_table_cell (in this same file) handles the same issue. Unsetting server side used elements, remaining elements are attributes.
Comment #13
Everett Zufelt CreditAttribution: Everett Zufelt commentedComment #14
JamesAn CreditAttribution: JamesAn commentedI can confirm the patch in #12 works against D7.10. I haven't touched D8 yet, so I didn't verify this.
Comment #15
BarisW CreditAttribution: BarisW commentedRe-rolled against D8. Works great, the invalid attribute is gone and the striping still works.
Comment #17
BarisW CreditAttribution: BarisW commented#15: remove-no-striping-in-theme_table-935066-15.patch queued for re-testing.
Comment #19
a.ross CreditAttribution: a.ross commentedAny news on this? Does the patch need a re-roll?
/me doesn't like invalid markup
Comment #20
fietserwinYes it did need a reroll (again). Strangely enough the patch from #10 applied nicely (after adding /core in front of the path names). apparently the white space removal in the patch from #15 was the problem.
Can you review as I can't review patches that (in the basis) are from my self.
I'm not sure that we still want to fix this nicely in D8 as it would probably need an API change. Also I still think that combining data and other things is quite common in array driven API's (see my comment in #12). So IMO, Dries' comment from #6 does no longer hold.
Comment #21
a.ross CreditAttribution: a.ross commentedIf Dries meant something along these lines:
...then I'm all for it.
Comment #22
a.ross CreditAttribution: a.ross commentedI also think it makes more sense to put the no_striping option in the root of the rows array, as opposed to on every row. And if my former suggestion makes sense, then it should also be done for the cells:
As such, I think it makes sense to fork an issue directed at a quick D7 fix. If this is agreed, I'll go ahead.
Comment #23
a.ross CreditAttribution: a.ross commentedI think we should do this. Forking 7.x as a separate issue: #1959110: theme_table outputs the no_striping option as an HTML attribute (followups)
Comment #24
fietserwin- Can you give any idea about the impact of this change on core itself (ie: how many uses of theme_table are there)?
- #9 suggests to open a different issue for the proper fix in D8, and use 1 issue for the quick fix in both D8 and D7. So I suggest to either use #1959110: theme_table outputs the no_striping option as an HTML attribute (followups) for the proper fix or start that one with the fix for D8 and leave this one open for the proper fix.
Comment #25
a.ross CreditAttribution: a.ross commentedThat makes no sense. A quick fix doesn't need all the discussion that has been going on in this one, an issue with impact on the API will. I don't think #9 really intended that this issue specifically is for the quick fix. Does it matter enough to make a fuss about it? The issue summary can be edited to reflect the fact that this will be the "proper 8.x fix" issue...
As for your other point, I think Dries pointing out he wants to separate stuff better is nuff said.
Comment #26
markabur CreditAttribution: markabur commentedSee also: #1649780: Remove first/last/odd/even classes in favor of CSS3 pseudo selectors
Comment #27
a.ross CreditAttribution: a.ross commentedAlso consider this example:
What??! Only the first row doesn't have a class for zebra striping, but the others do! I knew it made no sense to have that option on every table row, but this behavior is ridiculous, as it basically forces you to use the complex array structure for every row.
Comment #28
fietserwinWhen I look at #1649780: Remove first/last/odd/even classes in favor of CSS3 pseudo selectors (and #1942470: Zebra stripping gets messed up when rows are dynamically added/removed.), I think that this issue is going to be obsolete. The former is going to remove the no_striping "attribute" anyway, by replacing it by a separate zebra variable that will be passed to the theme. So I suggest to close this one as duplicate or won't fix and let's all join the discussion in #1649780: Remove first/last/odd/even classes in favor of CSS3 pseudo selectors.
Comment #29
a.ross CreditAttribution: a.ross commentedI beg to differ. This issue was caused because basically the API doesn't offer enough separation (see #6, #21 and #22). Removing the no_striping option (or moving it elsewhere) would solve this particular issue, but not the more general issue of the API, which wasn't addressed in #1649780: Remove first/last/odd/even classes in favor of CSS3 pseudo selectors.
It also looks like the other issue could still take some more time to complete, whereas this one will require a few trivial changes to the theme_table() function. Then we just need to fix the invocations across the codebase. Then again, I'm not sure how much work that would be, but views comes to mind.
Comment #29.0
a.ross CreditAttribution: a.ross commentedBroaden scope
Comment #29.1
a.ross CreditAttribution: a.ross commentedAdd some whitespace
Comment #29.2
a.ross CreditAttribution: a.ross commentedProperly add whitespace
Comment #29.3
a.ross CreditAttribution: a.ross commentedFix error
Comment #29.4
a.ross CreditAttribution: a.ross commentedClarify
Comment #29.5
a.ross CreditAttribution: a.ross commentedAdd some related issues.
Comment #30
a.ross CreditAttribution: a.ross commentedI've updated the issue summary to clarify the need for an API change. If anyone with enough permissions sees this, could the title be updated to reflect that?
Comment #31
markabur CreditAttribution: markabur commentedPlease change the author at the same time as changing the title. This issue was originally a quick 1-line fix for D7 (see #1), and now it's an API change that I don't even agree with, so I'd rather not be listed as the original author anymore. Thanks.
Comment #32
a.ross CreditAttribution: a.ross commentedComment #32.0
a.ross CreditAttribution: a.ross commentedtypo
Comment #33
effulgentsia CreditAttribution: effulgentsia commentedLooks like #1963340: Change field UI so that adding a field is a separate task will remove the only use case of 'no_striping' that we have in core. Given that, once that issue is done, how about removing it from theme_table() entirely for D8?
Comment #34
a.ross CreditAttribution: a.ross commentedHm, so what will happen in core? Will all tables have striping or none? And what will happen to contrib relying on this (or a similar) option?
I would prefer to either deprecate it or remove it in favor of zebra_striping (or both) but am not sure how I feel about removing it completely.
Comment #35
effulgentsia CreditAttribution: effulgentsia commentedThe original issue here about fixing the bug in the per-row no_striping is now RTBC in #1959110: theme_table outputs the no_striping option as an HTML attribute (followups).
Retitling this one for what the issue summary says, which is something else. Setting to active though, because the latest patch here doesn't do what the issue summary says, and I don't think there's consensus yet on doing that.
I still have hopes for #1649780: Remove first/last/odd/even classes in favor of CSS3 pseudo selectors making the striping decision purely a CSS one, in which case, theme_table() just outputs minimal markup and doesn't need any kind of striping related option passed to it. But there's no guarantee of that happening, so not marking this issue a duplicate quite yet.
The above is all just my 2 cents. If I misunderstood the intent of this issue, please correct.
Comment #36
markabur CreditAttribution: markabur commentedSorry, no, the API change needs to be its own issue.
I am totally opposed to an API change to fix this bug and it offends me that someone else can edit my original bug report to make it look like I am proposing one.
Comment #36.0
markabur CreditAttribution: markabur commentedSyntax error :/
Comment #37
markabur CreditAttribution: markabur commentedComment #38
markabur CreditAttribution: markabur commentedClosing this issue as a duplicate of #1959110: theme_table outputs the no_striping option as an HTML attribute (followups)
Comment #39
effulgentsia CreditAttribution: effulgentsia commentedSorry that this offended you; that certainly wasn't my intention, and I don't think it was anyone else's. It is very common for issues to have their scope/approach/etc. change over time, and with Drupal core being a collaborative process, it is appropriate for people to edit summaries and titles to reflect their understandings of the evolving scope. I think only drupal.org webmasters have permission to change the issue author field though. It would be great for d.o. to make it easier to change issue authorship, or make more visible that titles/summaries were updated by multiple people, but that's a topic for a different thread.
I think that's reasonable. @a.ross: can you open one and link to it from here if you'd still like to see that done?
Comment #40
markabur CreditAttribution: markabur commentedNo problem, it's just that the original report is about a tiny, insignificant, and specific bug, and this issue sat here for 2 years being about that bug. After all that time I would hate to see this bug report suddenly turn into a big change that affects core and contrib in non trivial ways, and is going to lead to all kinds of debate (yes the proposed change is of debatable value). Anyway, theme_table() is getting converted to twig *and* zebra striping classes are hopefully going away altogether *and* this bug was fixed over in the duplicate issue, so I see no reason to keep this one going. Thanks.
#1939008: Convert theme_table() to Twig
#1649780: Remove first/last/odd/even classes in favor of CSS3 pseudo selectors
#1959110: theme_table outputs the no_striping option as an HTML attribute (followups)
Comment #41
a.ross CreditAttribution: a.ross commentedI certainly didn't mean to offend anyone, just trying to get things done here. However to prevent offending mr special I'll make a new issue...
Comment #42
fietserwinHmmm, #1939008: Convert theme_table() to Twig still contains this error, set that one back to needs work.
Comment #43
a.ross CreditAttribution: a.ross commented#1965214: Improve the theme_table API
@fietserwin, of we could continue with our issue as a follow-up of that one.
Comment #43.0
a.ross CreditAttribution: a.ross commentedRevert to original bug report.