Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Feb 2016 at 12:17 UTC
Updated:
11 Aug 2023 at 17:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
steven jones commentedComment #3
nicrodgersGood catch. Might be better to use !empty rather than isset though?
Comment #4
danchadwick commentedInstructions to reproduce? I saw the same code in another path, but I don't see how these array elements can be missing. Empty strings, yes. Missing? Don't know how.
Comment #5
liam morlandIf you are still seeing this in the latest development version of Webform, please re-open and provide instructions to reproduce the issue.
Comment #6
kodiak324 commentedOne of our sites has an extremely complex webform with a lot of conditions and we are seeing this error. When a date field is hidden on a form because of a condition, a null gets passed to _webform_submit_date() and results in this notice being thrown. This also occurs with time fields in _webform_submit_date() and webform_time_convert().
Comment #7
kodiak324 commentedComment #8
liam morlandCan you create steps to reproduce? Does the patch work? If so, please make an issue fork with it.
Comment #9
kodiak324 commentedWhen a webform is submitted that has a date field hidden by a conditional, the following notice is thrown:
Notice: Trying to access array offset on value of type null in _webform_submit_date() (line 480 of /var/www/html/sites/all/modules/webform/components/date.inc).Similarly, when a webform is submitted that has a time field hidden by a conditional, the following two notices are thrown:
The referenced functions appear to receive the value ‘null’ for each field that is hidden by a conditional. Attempting to access array elements from a null value is not possible, so the notices are thrown.
Steps to reproduce:
This patch mitigates the warnings by using empty() to check for values instead of checking for empty strings in expected array elements. empty() suppresses the notices when the variable being checked is not actually an array, when the expected key is not set within the array, or when the array member contains an empty string or otherwise falsey value.
Tested with Drupal 7.81 and Webform 7.x-4.24 via the official Drupal Docker image.
Comment #12
jweowu commentedThis is the diff file for kodiak324's merge request !33 in comment #9. Please attribute it correctly if this is committed.
Attribution: kodiak324 at Rochester Institute of Technology
Comment #13
liam morlandComment #14
vladimirausThank you.
MR#33 tested and ready to be released.
I discovered #3365243: Deprecated function: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in webform_number_format_match() during testing.
Comment #16
liam morlandComment #17
liam morlandMerge request as a patch.
Comment #19
liam morland