Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
user.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Nov 2011 at 19:00 UTC
Updated:
4 Jan 2014 at 01:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
joachim commentedThe failure is in theme_item_list():
This lets through a $title of NULL. Anyone with a better grasp of PHP's empty/null/isset malarkey care to tackle this? :)
Comment #2
Everett Zufelt commentedAssuming that we never want an unset, NULL, or '' / 0 / '0' (empty) $title, we should use:
if (!empty($title)) { ... }
Assuming that we want to allow '0' or 0, we want:
// $title is set, is not NULL, and is not the empty string ''.
if (isset($title) && $title !== '') { ... }
Assuming that we want to allow '0', but not 0 (which evaluates to the empty string '')
// $title is set, is not NULL, and does not evaluate to the empty string ''.
if (isset($title) && $title != '') { ... }
My guess is that we want the third example.
Comment #3
Everett Zufelt commentedHmmm,
I'm wrong, '0' evaluates to '' too.
Comment #4
webchickHeh, read it and weep. :) http://php.net/manual/en/types.comparisons.php <3 PHP
Comment #5
Everett Zufelt commentedBottom line, do we want $title = '0' or 0 to be printed as 0, or ignored?
The attached patch will print $title if it does not evaluate to the empty string. So, $title will not be printed if $title=='0'. I think we can live with that here, I don't believe that we have a Coding Standard for rendering empty strings.
Comment #6
mgifford#5: theme_item_list-empty_title.patch queued for re-testing.
Comment #7
BrockBoland commentedCan anyone explain how to replicate this condition? I would test the patch, but I can't get it to NOT work in the first place.
Comment #8
mgiffordHave you got Drupal 8 up with the What's New block enabled?
Where are you stuck?
Comment #9
BrockBoland commentedmgifford: I've got a site running the 8.x HEAD and added both blocks to the sidebar. Both as an admin and anonymous user, I'm seeing the title on both blocks. I tried overriding the block titles to 0 or empty string, and it worked as expected (no h2 tags) in both cases.
Comment #10
joachim commented> Bottom line, do we want $title = '0' or 0 to be printed as 0, or ignored?
I suspect that if we don't allow a block title consisting of a single '0', someone down the line will file a bug because that's what they need...
Comment #11
mgiffordHere's a screenshot of HEAD before & after the patch is applied. Includes both the WAVE Toolbar report as well as the source. Try downloading http://wave.webaim.org/toolbar and running it against your system. You should see the same images.
I think this is ready to RTBC. Just it's hard to see if you don't know what to look for.
Comment #12
kgoel commentedReproduced the problem and got two empty heading errors (accessibility errors). Applied the patch and Voila! got no errors. Please see screenshots after patch was applied. I think it can be marked as RTBC.
I have been doing some accessibility work so picked this patch to test.
Comment #13
mgiffordThanks @kgoel. Do let us know if you'd like to be part of our monthly accessibility discussions announced http://groups.drupal.org/accessibility
Comment #14
kgoel commentedSure @mgifford. Please let me know if in anyway I can help out.
Comment #15
catchSorry I'm confused, 0 should not be equivalent to '' with a strict comparison, which is what the existing code has. So why can't we just check for isset and the strict check as suggested in #5?
Regardless, there should be a code comment explaining the accessibility issue.
Comment #16
kgoel commentedBased on Catch's comment #15. In this patch checking to see if title is set and its not null and empty string. Also added accessibility comment.
Comment #17
kgoel commentedTrying again with the right patch.
Comment #18
xjmThanks @kgoel! Setting NR for the bot to test it.
Comment #19
mgiffordThink the description could be clearer:
The bot needs to test the code though.
Comment #20
kgoel commentedupdated description :)
Comment #21
xjmAh, I think that is better comment text. Thanks @mgifford and @kgoel!
Attached cleans up the comment a bit more. RTBCing nonetheless because the changes from #20 are trivial.
Comment #22
catchThanks! Committed/pushed to 8.x.
This should probably be backported.
Comment #23
kgoel commentedD7 patch
Comment #24
kgoel commentedComment #26
kgoel commentedChanged version in the issue from 8.x to 7.x for backport.
Comment #27
Everett Zufelt commentedComment #28
Everett Zufelt commented#23: 1349722-23.patch queued for re-testing.
Comment #29
kgoel commentedFixed the commenting indenting. Updated patch for D7
Comment #30
xjmThanks @kgoel. The backport looks pretty good but needs one small change:
These comments should be indented by two spaces.
Comment #31
kgoel commentedThanks xjm! Learning something with each patch. Updated one for D7
Comment #32
kgoel commentedComment #33
xjmThat was fast! Setting "Needs review" so it will be tested. :)
Comment #34
xjmOh whoops, looks like I was posting at the same time as you! The indentation in #29 is correct--I was referring to the earlier version. :)
So RTBC for #29 (not #31).
Comment #35
kgoel commentedThanks xjm!
Comment #36
webchickCommitted and pushed #29 to 7.x. Thanks!