[buddypress-trac] [BuddyPress Trac] #5731: text/number profile fields not rendered if value == 0
buddypress-trac
noreply at wordpress.org
Mon Jul 14 13:48:43 UTC 2014
#5731: text/number profile fields not rendered if value == 0
-----------------------------------+-----------------------
Reporter: DJPaul | Owner: djpaul
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 2.1
Component: XProfile | Version: 1.0
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion |
-----------------------------------+-----------------------
Changes (by boonebgorges):
* keywords: has-patch => has-patch 2nd-opinion
Comment:
Thanks for the patch, WCUADD.
We're ending up with a proliferation of type checks in the form submission
handlers, which to me is a code smell. What is the purpose of doing
`empty()` checks here in the first place? As I see it, we are just trying
to figure out whether there's a value in the `$_POST` array for us to use
(mainly to avoid PHP notices). For that purpose, `isset()` will work just
fine. Type validation and other such business should be left to the
validation methods in the field types themselves. Swapping out `! empty()`
for `isset()` in these cases will let empty string values through. But (a)
for some field types, an empty string is a valid input, and (b) for those
where it's *not*, the `is_valid()` check will fail, which will produce a
failed form submit.
This approach seems much more sane to me. What do others think?
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5731#comment:11>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list