Error: Call to undefined function each() in apachesolr_multilingual_fields_default_indexing_callback_implementation()

Created on 30 August 2022, over 2 years ago
Updated 1 August 2023, over 1 year ago

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,

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇱Israel imjweb

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024