Problem/Motivation
The search index can contain items that are not available in Drupal's database or otherwise cannot be loaded as entities. This may happen when the site is run from an old database backup but on the newest search index.
When a search is executed and a deleted (not available) entity matches, the following error occurs on the result page:
Drupal\search_api\SearchApiException: Failed to load original object entity:node/5620:en in Drupal\search_api\Item\Item->getOriginalObject() (line 185 of modules/contrib/search_api/src/Item/Item.php).
Proposed resolution
The SearchApiPageController loads the original object and checks whether it casts to FALSE, continuing the loop if so. However, getOriginalObject() will throw a SearchApiException when it couldn't load the entity.
The call to getOriginalObject() needs to be in a try catch block that continues the loop whenever the exception occurs.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2872984-2.patch | 1.04 KB | dietr_ch |
Comments
Comment #2
dietr_ch commentedComment #3
borisson_This looks solid.
Comment #6
drunken monkeyCommitted.
Thanks, everyone!