- Issue created by @rupertj
- Merge request !4Add default_time_zone_source to date_recur field defaults. → (Open) created by rupertj
- 🇬🇧United Kingdom rupertj Bristol, UK
I've pushed that change to the MR. It fixed the issue for me.
I've installed finders and finders_events on an existing site, and upgraded localgov_events from 3.x to 4.x. As there's no upgrade path for localgov_events yet, I had to re-do the existing configuration for it in the UI.
When trying to create my first event node, the node form page failed with:
The website encountered an unexpected error. Try again later.
DateInvalidTimeZoneException: DateTimeZone::__construct(): Unknown or bad timezone () in DateTimeZone->__construct() (line 25 of modules/contrib/date_recur/src/Plugin/Field/DateRecurDateTimeComputed.php).
Drupal\date_recur\Plugin\Field\DateRecurDateTimeComputed->getValue() (Line: 154)
Drupal\Core\Field\FieldItemBase->__get() (Line: 154)
Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularAlphaWidget->formElement() (Line: 459)
Drupal\Core\Field\WidgetBase->formSingleElement() (Line: 219)
Drupal\Core\Field\WidgetBase->formMultipleElements() (Line: 120)
Drupal\Core\Field\WidgetBase->form() (Line: 190)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm() (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form() (Line: 134)
Drupal\node\NodeForm->form() (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 23)
The timezone is set on the field definition though. I stepped through the code to find why the tz value is missing, and eventually got to this point in field_recur, where the default value is set on a newly created node: https://git.drupalcode.org/project/date_recur/-/blob/3.9.x/src/Plugin/Fi...
The default timezone is only used if requested. IE, if default_time_zone_source is set to DateRecurFieldItemList::DEFAULT_TIME_ZONE_SOURCE_FIXED.
I'm going to add this to the field that this module creates and see if it helps.
Needs work
1.0
Code
I've pushed that change to the MR. It fixed the issue for me.