When a date field has a default value, it generates this warning:

    Warning: Illegal string offset 'month' in form_process_date() (line 2962 of includes/form.inc).
    Warning: Illegal string offset 'day' in form_process_date() (line 2962 of includes/form.inc).
    Warning: Illegal string offset 'year' in form_process_date() (line 2962 of includes/form.inc).

Patch attached...When a date field has a default value, it generates this warning:

CommentFileSizeAuthor
#4 webform_date_54-2079665.patch728 bytesquicksketch
date.patch608 bytescolemanw

Comments

quicksketch’s picture

Title: Patch fixes undefined index warning on date fields » Patch fixes undefined index warning on date fields (PHP 5.4)

Thanks, this seems like it's a PHP 5.4 only issue, as reported here: #1760532: PHP 5.4 Warning: Illegal string offset 'month' | 'day' | 'year' in form_process_date() (line 2943 of drupal7/includes/form.inc).

I think this patch is safe, but it could probably use a comment why we're doing this. It might also cause an error in PHP 5.3 (since I don't think #value should be defined to start with), we'll need to double-check.

peacog’s picture

The patch solves the problem for me. Thanks.

sonicthoughts’s picture

Looks good. Please consider commit to 4

quicksketch’s picture

Version: 7.x-4.0-alpha10 » 8.x-4.x-dev
Status: Needs review » Patch (to be ported)
StatusFileSize
new728 bytes

Marked #1760532: PHP 5.4 Warning: Illegal string offset 'month' | 'day' | 'year' in form_process_date() (line 2943 of drupal7/includes/form.inc) duplicate.

I added a comment and condition to make sure this change is safe. Not sure if this is needed in Drupal 8 or not, but moving it to be ported/reviewed.

Committed this version to 7.x-4.x.

fenstrat’s picture

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

Committed to 8.x-4.x in 3e728f3. Thanks!

Given the 8.x branch isn't yet in any working condition to test this I committed this in an effort to keep the 7.x and 8.x in sync as much as possible.

Status: Fixed » Closed (fixed)

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

GrantI’s picture

Issue summary: View changes

This patch worked well for me. I'm using Drupal 7.26 and Webfrom 7.x-3.20. The file you edit is in sites>all>modules>webform>components>dates.inc

NaX’s picture

Version: 7.x-4.x-dev » 7.x-3.x-dev
Issue summary: View changes
Status: Closed (fixed) » Needs work

Can we also have this also committed to the 3.x branch. Upgrading to 4.x is not always desirable and the warnings also appear on the 3.x version.

  • Commit d4e1c50 on 7.x-3.x by fenstrat:
    Issue #2079665 by quicksketch, colemanw: Patch fixes undefined index...
fenstrat’s picture

Version: 7.x-3.x-dev » 7.x-4.x-dev
Status: Needs work » Fixed

Yep fair enough. Committed and pushed to 7.x-3.x.

quicksketch’s picture

Thanks @fenstrat!

Status: Fixed » Closed (fixed)

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

Jorrit’s picture

The same fix also works for 6.x-3.x. Could it be pushed there as well too?

NaX’s picture

Version: 7.x-4.x-dev » 6.x-3.x-dev
Status: Closed (fixed) » Needs work
danchadwick’s picture

Status: Needs work » Closed (won't fix)

Closing for lack of maintenance on the 6.x branch. If a maintainer for 6.x comes forward, he/she can re-open.