Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
26 Oct 2015 at 17:19 UTC
Updated:
12 Dec 2016 at 19:34 UTC
Jump to comment: Most recent, Most recent file
Extra safety for "exclude_empty" property that may be undefined. This patch prevent notices and make code readable.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | interdiff-12-14.txt | 6.08 KB | br0ken |
| #16 | webform-exclude_empty-2601546-14.patch | 1.61 KB | br0ken |
| #12 | interdiff-8-12.txt | 4.18 KB | br0ken |
| #12 | webform-exclude_empty-2601546-12.patch | 7.52 KB | br0ken |
Comments
Comment #2
br0kenComment #3
br0kenComment #4
br0kenComment #5
l0keAgree, using
empty()is incorrect here. And it's definitely more clear to read.#3 looks great, RTBC.
Comment #6
danchadwick commented1) exclude_empty should never be absent. It comes from the database, which does not accept NULL values. If it is absent, the source of the error is elsewhere. Webform's policy is NOT to safety check data which should never be invalid. It leads to excess code and allows sloppiness elswhere.
2) I like the use of implode().
3) I do not like deleting the comment about grids, which provides the motivation for the code. We need to remember that we are writing these comments not for us, who may remember the issues involved, but for future webform maintainers.
I would support a patch that only simplifies this with implode().
Comment #7
br0kenIf you want be so strict, then need to use type casting at least for
webform_submission_render()function and remove these lines of code:Agreed about code comments. My bad.
Comment #8
br0ken@DanChadwick, If you will not contradict yourself, then this patch should be better.
Comment #10
br0kenAnd the problems is not long in coming. You not check for
!empty()and, otherwise, check forNULLand for key existence.Comment #11
danchadwick commentedexcluded_components is an optional parameter. This why the formal argument is set to NULL, a valid case that the code needs to handle.
D7 and webform generally don't put types in doc blocks. I don't object, but they shouldn't use namespaces. excluded_components can be NULL or an array of integers, or an array of strings.
Don't insult me. I'm volunteering my time.
I have no idea what you are saying. empty(), like is_set(), does not raise exceptions when the parameter is undefined. empty() returns TRUE for ("0"), which is sometimes desired but often not.
Comment #12
br0kenShould be optional, as is, but with type
arrayandarray()as default value.D7 is not ideal, we can make it better using our forces :)
I didn't want to offend you, I apologize.
Here is a better approach.
Comment #13
danchadwick commentedYou're changing the API after it's been in use. If someone passes NULL, your change will fail.
I don't see much gain in this beyond the implode() improvement and adding a webform-standard doc block. The right place to make these changes would be in the D8 branch.
There isn't any current bug. We're fiddling with code for no functional improvement. This is not a high reward area of endeavour. I would suggest focusing your energies on either new D7 features, D7 issues, or the D8 branch. I know I am.
Comment #14
br0kenI knew that you write something like this.
Comment #15
danchadwick commentedComment #16
br0kenThink we must be progressive but I know that you leave this as is.
Here is the "better" by your opinion, but I'm sure for 90% that your next comment will contain something like this:
I have another opinion, but you are maintainer with rights for decision.
Comment #17
danchadwick commentedYour patch looks good. Nice improvement. Needs testing, which I haven't done yet.
Enough with the ad hominem comments. Let's keep this about the code.
Comment #18
l0keEven thought exclude_empty should never be absent, in #2499749: Notice: Undefined index: exclude_empty it is absent. Yes, this notice caused by incorrect usage in Webform2PDF module, but I think this condition change can really prevent such notices, and it doesn't lead to excess code at all.
So again I think it's good to go.
Comment #19
danchadwick commentedRe #18 -- As a matter of policy, we don't work around incompatibilities in other modules -- they get their own fixes. The code in question is good because $email may be null, not because $email['exclude_empty'] may be undefined.
Comment #20
br0ken@DanChadwick, so, will this be merged?
Comment #21
danchadwick commented@BROkEN -- I resigned as primary maintainer. That's up to quicksketch now.
Comment #23
danchadwick commentedCommitted to 7.x-4.x.
Comment #24
danchadwick commentedComment #25
danchadwick commentedComment #26
fenstratClosing to clear out the old Webform 8.x-4.x branch. See #2827845: [roadmap] YAML Form 8.x-1.x to Webform 8.x-5.x.