Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Item::getFields() has this code right now:
try {
Utility::extractFields($this->getOriginalObject(), $fields_by_property_path);
}
catch (SearchApiException $e) {
// If we couldn't load the object, just log an error and fail
// silently to set the values.
watchdog_exception('search_api', $e);
}
But that exception is not thrown, instead, it gives a recoverable fatal error because we pass in NULL to that method.
When that is fixed, in views, there is a similar issue because $row->_item isn't properly loaded. Added an additional safeguard on that too.
Comment | File | Size | Author |
---|---|---|---|
#1 | avoid-fatals-2353495-1.patch | 1.65 KB | Berdir |
Comments
Comment #1
BerdirComment #2
drunken monkeyThanks for opening this, I guess this really makes a lot of sense. At least we currently don't check this return value for
NULL
anywhere.However, when changing this code, we of course also have to change the associated interface documentation to add the necessary
@throws
tag.I fixed that, and also added a
try
/catch
in theHighlight
processor. In all other processors, the method is only called inpreprocessIndexItems()
, where an original object should always be set. Otherwise, we have an exception there instead of a fatal error, which is also an improvement.So, committed with these two changes. Thanks again!