Comments

BR0kEN created an issue. See original summary.

br0ken’s picture

Status: Active » Needs review
StatusFileSize
new1.72 KB
br0ken’s picture

StatusFileSize
new1.69 KB
br0ken’s picture

StatusFileSize
new517 bytes
l0ke’s picture

Status: Needs review » Reviewed & tested by the community

Agree, using empty() is incorrect here. And it's definitely more clear to read.
#3 looks great, RTBC.

danchadwick’s picture

Status: Reviewed & tested by the community » Needs work

1) 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().

br0ken’s picture

If you want be so strict, then need to use type casting at least for webform_submission_render() function and remove these lines of code:

+++ b/includes/webform.submissions.inc
@@ -636,22 +636,18 @@ function webform_submission_render($node, $submission, $email, $format, $exclude
   // Remove excluded components.
   if (is_array($excluded_components)) {

Agreed about code comments. My bad.

br0ken’s picture

Assigned: Unassigned » br0ken
Status: Needs work » Needs review
StatusFileSize
new3.92 KB
new3.12 KB

@DanChadwick, If you will not contradict yourself, then this patch should be better.

Status: Needs review » Needs work

The last submitted patch, 8: webform-exclude_empty-2601546-8.patch, failed testing.

br0ken’s picture

And the problems is not long in coming. You not check for !empty() and, otherwise, check for NULL and for key existence.

danchadwick’s picture

excluded_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.

@DanChadwick, If you will not contradict yourself,

Don't insult me. I'm volunteering my time.

And the problems is not long in coming. You not check for !empty() and, otherwise, check for NULL and for key existence.

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.

br0ken’s picture

Status: Needs work » Needs review
StatusFileSize
new7.52 KB
new4.18 KB

excluded_components is an optional parameter. This why the formal argument is set to NULL, a valid case that the code needs to handle.

Should be optional, as is, but with type array and array() as default value.

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.

D7 is not ideal, we can make it better using our forces :)

Don't insult me. I'm volunteering my time.

I didn't want to offend you, I apologize.

Here is a better approach.

danchadwick’s picture

Status: Needs review » Needs work

You'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.

br0ken’s picture

I knew that you write something like this.

danchadwick’s picture

Status: Needs work » Closed (works as designed)
br0ken’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new1.61 KB
new6.08 KB

Think 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 like "implode()" but "empty()" is really useless.

I have another opinion, but you are maintainer with rights for decision.

danchadwick’s picture

Your 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.

l0ke’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/includes/webform.submissions.inc
@@ -636,22 +636,18 @@ function webform_submission_render($node, $submission, $email, $format, $exclude
-    if ($email && $email['exclude_empty']) {
+    if (!empty($email['exclude_empty'])) {

Even 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.

danchadwick’s picture

Re #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.

br0ken’s picture

@DanChadwick, so, will this be merged?

danchadwick’s picture

@BROkEN -- I resigned as primary maintainer. That's up to quicksketch now.

  • DanChadwick committed 336df04 on 7.x-4.x
    Issue #2601546 by BR0kEN: Added improvement to e-mail "exclude_empty"...
danchadwick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-4.x.

danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Status: Fixed » Patch (to be ported)
danchadwick’s picture

Category: Feature request » Task
fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Status: Patch (to be ported) » Fixed

Closing 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.

  • DanChadwick committed 336df04 on 8.x-5.x
    Issue #2601546 by BR0kEN: Added improvement to e-mail "exclude_empty"...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.