Just built a webform with a date component and I'm seeing the following errors. Anyone have ideas what I might be doing wrong?

# warning: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (user) in /webform/components/date.inc on line 527.
# warning: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given in /webform/components/date.inc on line 528.

I'm seeing three of these. I assume it's one for each of the date fields (day, month, year).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Do you have any date-related modules installed? Webform is specifically tailored to work with DateAPI (part of the Date module package), and it should work without DateAPI. If you've got some other date-related module installed, it may be setting the $user->timezone property to something that Webform is not expecting (apparently "user" in this case).

attheshow’s picture

The only date related modules I have turned on are:

Date 6.x-2.4
Date API 6.x-2.4
Date Popup 6.x-2.4
Date Timezone 6.x-2.4

realityloop’s picture

I'm also getting this error, the following date related submodules are active:

Date 6.x-2.x-dev
Date API 6.x-2.x-dev
Date Popup 6.x-2.x-dev
Date Timezone 6.x-2.x-dev

Just before line 518 of date.inc

dpm($timezone_name);  result=user
dpm($GLOBALS['user']->timezone_name); result = (nothing returned)
dpm(variable_get('date_default_timezone_name', NULL));  result = Australia/Melbourne
dpm(variable_get('configurable_timezones', 1));  result = 0

Just found that the error's go away if I enable user configurable timezones in Date and time settings, so it's not handling defined timezone properly by the look of it.

This can be resolved by changing line 521 to:

  if (!empty($timezone_name)) {

I also think line 523 needs to be removed:

    $timezone_name = NULL;

I'm not sure its the right fix tho..

realityloop’s picture

Status: Active » Needs review
FileSize
834 bytes

Patch attached

quicksketch’s picture

Status: Needs review » Fixed
FileSize
681 bytes
817 bytes

Thanks realityloop, I have no idea what that "$timezone = NULL" line was doing in there. The check you added isn't quite correct, since we don't want to always blow away the user-timezone. Instead we only want to set the timezone if $timezone == NULL or 'user'. I've committed this patch to both 3.x branches.

Status: Fixed » Closed (fixed)

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

arpieb’s picture

Status: Closed (fixed) » Active

Hi there. I'm getting the same errors with the following date-related modules installed and enabled in D6.17:

Calendar 6.x-2.2
Date API 6.x-2.4
Date Popup 6.x-2.4 (configured to use default jQuery date picker)
Date Repeat API 6.x-2.4
Date Timezone 6.x-2.4 (configured for America/New_York, disabled user timezone, first day Sunday)
Webform 6.x-3.0-beta6 (was getting the same error with 6.x-2.9, tried upgrading after reading this thread to get latest patches)

Errors are the following with one date field (popup enabled) and one time field:

    * warning: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (user) in /homepages/16/d282277974/htdocs/dev.octobang.com/mms/sites/all/modules/webform/components/date.inc on line 527.
    * warning: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given in /homepages/16/d282277974/htdocs/dev.octobang.com/mms/sites/all/modules/webform/components/date.inc on line 528.
    * warning: DateTime::format() [datetime.format]: The DateTime object has not been correctly initialized by its constructor in /homepages/16/d282277974/htdocs/dev.octobang.com/mms/sites/all/modules/webform/components/date.inc on line 529.
    * warning: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (user) in /homepages/16/d282277974/htdocs/dev.octobang.com/mms/sites/all/modules/webform/components/date.inc on line 527.
    * warning: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given in /homepages/16/d282277974/htdocs/dev.octobang.com/mms/sites/all/modules/webform/components/date.inc on line 528.
    * warning: DateTime::format() [datetime.format]: The DateTime object has not been correctly initialized by its constructor in /homepages/16/d282277974/htdocs/dev.octobang.com/mms/sites/all/modules/webform/components/date.inc on line 529.

If I enable user timezones in 'Date Timezone' the error goes away - maybe that is a clue as to what is still happening?

-R

quicksketch’s picture

Status: Active » Fixed

The problem has already been fixed in CVS but is not included in the beta6 version (which was released June 20). This problem was fixed June 30. You can use the development version of Webform 3.x, or you can wait for the next release.

arpieb’s picture

Status: Fixed » Closed (fixed)

Gotcha. I guess when I saw:

I've committed this patch to both 3.x branches.

I (incorrectly) thought the patches had been applied to the dev AND beta branches... Should have paid closer attention to the patch and build dates... Sorry!

For now I'm just going to leave the user timezone setting in place as it's not a real issue at this point. New site, no user accounts yet - and what is one more config option when you create an account anyway? ;)

Thanks for a great module! Keep up the great work!