After upgrading to 7.x-2.11, I get the following errors when rendering in a view the value or value2 of a date field indexed with search_api (available in the view e.g. as "Birthdate: start date (indexed)" field):

Notice: Undefined index: field in date_entity_metadata_struct_getter() (Zeile 676 von /var/www/drupal/sites/all/modules/contrib/date/date.module).
Notice: Trying to access array offset on value of type null in date_entity_metadata_struct_getter() (Zeile 676 von /var/www/drupal/sites/all/modules/contrib/date/date.module).

#2123039: Default timezone setting mismatch in metadata wrapper integration introduced changes to date_entity_metadata_struct_getter():

-  $timezone_db = !empty($item['timezone_db']) ? $item['timezone_db'] : 'UTC';
+  $timezone_db = date_get_timezone_db($info['field']['settings']['tz_handling']);

The problem here is that for these fields, there is no $info['field'] available, $item['timezone_db'] is though. So it works with the code from 7.x-2.10, but not with 7.x-2.11.

However, $info['parent']['info']['field']['settings']['tz_handling'] exists.

I don't know who should provide the field data here, search_api or entity, but maybe date should consider that the field data might not be available.

Comments

Ronino created an issue. See original summary.

damienmckenna’s picture

Status: Active » Closed (duplicate)
Parent issue: » #2074457: Error messages from date_entity_metadata_struct_getter()

This should be fixed in #2074457.

ronino’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new849 bytes

While #2074457: Error messages from date_entity_metadata_struct_getter() is about $item[$name] not being set, this is about $info['field']. This is not related.

The attached patch takes a first try to use the new behavior to determine timezone data if $info['field'] is given, otherwise it uses 2.10's way.

ronino’s picture

On reproducibility: The notices are triggered only for date fields the subfields value and value2 of which have been indexed by search_api individually (listed at /admin/config/search/search_api/index/[index]/fields like "field_some_date:value", "...:value2" and such). They're not triggered for date fields that have been indexed as a whole (listed as "field_some_date2").

jplana’s picture

Status: Needs review » Reviewed & tested by the community

+RTBC I can confirm the patch fixes the problem. Also worth noting that I agree with @Ronino, this issue is unrelated with #2074457

Reproducibility: We were able to reproduce it without using search_api. In our case there was a warning wall in an entity form with multiple date fields.

joelpittet’s picture

Version: 7.x-2.11 » 7.x-2.x-dev
jplana’s picture

StatusFileSize
new67.76 KB

Just to add a bit more context:

The date.module expect the field to have defined timezone settings, but this is an optional field setting, that will only show up if the field has time (hours, minutes, seconds). Attached screenshot to clarify.

field settings timezone

  • DamienMcKenna committed 9071bd3 on 7.x-2.x authored by Ronino
    Issue #3202888 by Ronino, jplana, DamienMcKenna, joelpittet: Undefined...
damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you.

.bert’s picture

Thank you for this @Ronino!

This fixed an issue we saw related to tokens in Rules no longer converting for the timezone.

Status: Fixed » Closed (fixed)

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