Since 6.x-3.x is a backport of the D7 branch, there are some things still designed for D7 data formats, and this is one of them. In D7, date field arrays are keyed by the language code, hence this line:

list($lang, $values) = each($field);

However, D6 dates are keyed by integers, with multiple dates being possible as separate keyed arrays in the field (i.e. $node->field_mydate[0], $node->field_mydate[1], etc). As such, the function doesn't work very well as currently written. The attached patch modifies the function to correctly handle the date field structure in D6.

On a side -but related to this issue - note (let me know if this should be a separate issue), should this field be able to handle the case where a single value date field - such as one that is to be used for sorting (Solr requires single value fields for sorting) - is used? Date fields are assumed to be multivalued when mappings are being created in apachesolr_entity_fields(), but if hook_apachesolr_field_mappings_alter() has been used to set multiple=FALSE or the mapping has been defined with hook_apachesolr_field_maps with multiple=FALSE, then there will be multiple values returned at the end of this date callback, and a 400 Bad Request error will be returned from Solr.

Is it standard practice in this case to create a custom callback for single date fields and define that in the field mapping with the alter hook? Or should we modify the default callback to handle that case?

Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nick_vh’s picture

Status: Needs review » Closed (fixed)

Committed, thanks!