diff --git a/search_api.module b/search_api.module index 2cf1cece..ccbd9990 100644 --- a/search_api.module +++ b/search_api.module @@ -8,6 +8,7 @@ use Drupal\comment\Entity\Comment; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\ContentEntityType; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; @@ -762,7 +763,8 @@ function search_api_entity_extra_field_info() { * Implements hook_entity_view(). */ function search_api_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { - if ($display->getComponent('search_api_excerpt') && isset($build['#search_api_excerpt'])) { + $excerpt_component = $display->getComponent('search_api_excerpt'); + if ($excerpt_component !== NULL && isset($build['#search_api_excerpt'])) { $build['search_api_excerpt'] = [ '#type' => 'markup', '#markup' => $build['#search_api_excerpt'],