In apachesolr_multilingual_term_reference_indexing_callback_implementation when language is undefined the PHP function "each()" is used to build key/values.
Since "reset()" is not called on the array, it is not garanteed that the internal pointer is at the "beginning" of the array.
This occurs on line 296 in the file apacesolr_multilingual.index.inc. Adding a "reset($node->{$field_name});" before line 296 should solve the issue.
Original code:
if (array_key_exists($node->language, $node->{$field_name}) && is_array($node->{$field_name}[$node->language])) {
$items = $node->{$field_name}[$node->language];
}
else {
list($lang, $items) = each($node->{$field_name});
if (!is_array($items)) {
$items = array();
}
}
With reset:
if (array_key_exists($node->language, $node->{$field_name}) && is_array($node->{$field_name}[$node->language])) {
$items = $node->{$field_name}[$node->language];
}
else {
reset($node->{$field_name});
list($lang, $items) = each($node->{$field_name});
if (!is_array($items)) {
$items = array();
}
}
Comments
Comment #2
candalt commentedComment #3
candalt commentedComment #4
wonder95 commentedWith the deprecation of the each() function in PHP 7.2.0, I came up with a much simpler and easier to read method of doing this:
Although it has to be modified for apachesolr_multilingual_term_reference_indexing_callback_implementation(), since for some reason it's different from all the other functions in this file and passes in $node and creates $items instead of $entity and $values:
Comment #5
ludo.rI applied patch #3 and it solves my issue. Terms were not indexed before the patch, now they are. :)
I didn't try patch #4 however.
Comment #6
ludo.rPlease note that the each issue is already addressed in #2998996: [ PHP 7.2 Compatibility ] - Function each() is deprecated since PHP 7.2; Use a foreach loop instead.
Comment #7
ludo.r