array_intersect error if fallback language field is unknown

Created on 18 July 2024, 5 months ago
Updated 5 August 2024, 5 months ago

Respect the submission guidelines above! Drupal.org issue forks cause additional work for the project maintainer!

Setup

  • Solr version: 8.11.1
  • Drupal Core version:10.2.6
  • Search API version:8.x-1.34
  • Search API Solr version: 4.3.3
  • Configured Solr Connector: Solr Cloud with Basic Auth
  • PHP: 8.2

Issue

When the fallback language field is configured but no present in the doc_fields, a warning is thrown:
Undefined array key "sm_language_with_fallback" SearchApiSolrBackend.php:2974

And an error is later produced in the array_intersect call:
[error] TypeError while trying to render item entity:node/1371:nl with view mode default for search index Default Index: array_intersect(): Argument #2 must be of type array, null given in array_intersect() (line 2975 of /public_html/web/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php).

This should be checked with an isset.
if ($fallback_language_field && !empty($languages) && isset($doc_fields[$fallback_language_field])) {

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇧🇪Belgium kriboogh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024