Commit 47ccf060 authored by Thomas Seidl's avatar Thomas Seidl
Browse files

Issue #3308184 by drunken monkey, admirlju: Fixed handling of incomplete field...

Issue #3308184 by drunken monkey, admirlju: Fixed handling of incomplete field definitions when generating Views data.
parent 4c20bcc0
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
Search API 1.x, dev (xxxx-xx-xx):
---------------------------------
- #3308184 by drunken monkey, admirlju: Fixed handling of incomplete field
  definitions when generating Views data.
- #3392465 by drunken monkey: Fixed use of location filter together with AND
  facets in DB backend.
- #3293474 by admirlju, jhedstrom, drunken monkey: Added configurable maximum
+7 −4
Original line number Diff line number Diff line
@@ -198,8 +198,11 @@ function _search_api_views_get_handlers(FieldInterface $field) {
  try {
    $types = [];

    $definition = NULL;
    if ($field->getPropertyPath() !== NULL) {
      $definition = $field->getDataDefinition();
    $entity_type_id = $definition->getSetting('target_type');
    }
    $entity_type_id = $definition?->getSetting('target_type');
    if ($entity_type_id) {
      $entity_type = \Drupal::entityTypeManager()
        ->getDefinition($entity_type_id);
@@ -215,11 +218,11 @@ function _search_api_views_get_handlers(FieldInterface $field) {

    // Special treatment for languages (as we have no specific Search API data
    // type for those).
    if ($definition->getSetting('views_type') === 'language') {
    if ($definition?->getSetting('views_type') === 'language') {
      $types[] = 'language';
    }

    if ($definition->getSetting('allowed_values')) {
    if ($definition?->getSetting('allowed_values')) {
      $types[] = 'options';
    }

+6 −1
Original line number Diff line number Diff line
@@ -473,11 +473,16 @@ class Field implements \IteratorAggregate, FieldInterface {
    if (!isset($this->dataDefinition)) {
      $definitions = $this->getIndex()
        ->getPropertyDefinitions($this->getDatasourceId());
      if ($this->getPropertyPath() === NULL) {
        $field_label = $this->getLabel() ?: $this->getFieldIdentifier();
        $index_label = $this->getIndex()->label();
        throw new SearchApiException("Field '$field_label' on index '$index_label' has no property path set.");
      }
      $definition = \Drupal::getContainer()
        ->get('search_api.fields_helper')
        ->retrieveNestedProperty($definitions, $this->getPropertyPath());
      if (!$definition) {
        $field_label = $this->getLabel();
        $field_label = $this->getLabel() ?: $this->getFieldIdentifier();
        $index_label = $this->getIndex()->label();
        throw new SearchApiException("Could not retrieve data definition for field '$field_label' on index '$index_label'.");
      }