Fatal error on indexing

Created on 10 June 2025, about 2 months ago

Problem/Motivation

When indexing, I'm running into a fatal error:

[error]  Error: Call to a member function hasWarnings() on null in Drupal\search_api\Entity\Index->indexSpecificItems() (line 1057 of /var/www/html/docroot/modules/contrib/search_api/src/Entity/Index.php) #0 /var/www/html/docroot/modules/contrib/search_api/src/Entity/Index.php(974): Drupal\search_api\Entity\Index->indexSpecificItems(Array)

Looking at the code

        $item = $items[$item_id] ?? NULL;
        if ($item->hasWarnings()) {
          $items_with_warnings[$item_id] = $item_id;
        }

$item can be null, since ?? is used, so the next statement should take this into account. Something like:

        $item = $items[$item_id] ?? NULL;
        if ($item && $item->hasWarnings()) {
          $items_with_warnings[$item_id] = $item_id;
        }
🐛 Bug report
Status

Needs review

Version

1.0

Component

General code

Created by

🇧🇪Belgium mr.baileys 🇧🇪 (Ghent)

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

Comments & Activities

Production build 0.71.5 2024