I'm upgrading to php 8 and receive an error when I try to index the search. It is related to the each() function which is evidently deprecated in php 8 and appears several times in the file.
I understand that foreach() should replace it, but how should that be rewritten in the context of the function?

function apachesolr_multilingual_date_default_indexing_callback_implementation($entity, $field_name, $index_key, array $field_info) {
  $fields = array();
  if (!empty($entity->{$field_name})) {
    $field = $entity->$field_name;
    $values = array();
    if (array_key_exists($entity->language, $field) && is_array($field[$entity->language])) {
      $values = $field[$entity->language];
    }
    else {
      list($lang, $values) = <strong>each($field);</strong>
      if (!is_array($values)) {
        $values = array();
      }
    }

Thanks,

Comments

imjweb created an issue. See original summary.

liam morland’s picture

Issue tags: -php 8 +PHP 8.0
Zertimon’s picture

Zertimon’s picture

Correction.

Zertimon’s picture

liam morland’s picture

Status: Active » Needs review