Commit 01308680 authored by Markus Kalkbrenner's avatar Markus Kalkbrenner Committed by Thomas Seiber
Browse files

Issue #3306204 by mkalkbrenner, drunken monkey: Added a new query option for...

Issue #3306204 by mkalkbrenner, drunken monkey: Added a new query option for passing non-standard language filters to the backends.
parent 1bbfe92f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
Search API 1.x, dev (xxxx-xx-xx):
---------------------------------
- #3306204 by mkalkbrenner, drunken monkey: Added a new query option for
  passing non-standard language filters to the backends.
- #3262092 by attilatilman, japerry, drunken monkey, Berdir: Fixed several
  problems regarding Drupal 10 compatibility.
- #3292775 by Berdir, drunken monkey: Fixed most deprecations preventing Drupal
+11 −5
Original line number Diff line number Diff line
@@ -29,16 +29,22 @@ class SearchApiLanguage extends LanguageFilter {
    // Only set the languages using $query->setLanguages() if the condition
    // would be placed directly on the query, as an AND condition.
    $query = $this->getQuery();
    $direct_language_condition = $this->realField === 'search_api_language'
      && $this->operator == 'in'
      && $query->getGroupType($this->options['group'])
      && $query->getGroupOperator() == 'AND';
    if ($direct_language_condition) {
    $op_in_required = $this->operator == 'in'
      && $query->getGroupType($this->options['group']) === 'AND'
      && $query->getGroupOperator() === 'AND';
    if ($this->realField === 'search_api_language' && $op_in_required) {
      $query->setLanguages($this->value);
    }
    else {
      parent::query();
    }

    // Also add a query option for any direct language filter including all
    // included languages, in case any component needs this information in
    // addition to the filter we placed.
    if ($op_in_required && $this->value) {
      $query->setOption('search_api_included_languages', array_values($this->value));
    }
  }

}
+4 −0
Original line number Diff line number Diff line
@@ -435,6 +435,10 @@ interface QueryInterface extends ConditionSetInterface {
   *     should be returned along with the results by the backend, if possible.
   *     For backends that support retrieving fields values, this allows them to
   *     only retrieve the values that are actually needed.
   *   - search_api_included_languages: A list of all languages that should be
   *     included in the query, in case there were any restrictions. This is
   *     mostly helpful if getLanguages() returns NULL but there might still be
   *     just a subset of all available languages included.
   *   However, contrib modules might introduce arbitrary other keys with their
   *   own, special meaning. (Usually they should be prefixed with the module
   *   name, though, to avoid conflicts.)