Skip to content

Commit

Permalink
Revert search_api_language filter ID change in search views
Browse files Browse the repository at this point in the history
In #3470 we changed the search_api_language filter to a
language_with_fallback filter to ensure that users could find matching
content in different languages if no version in their own language was
available. However, this also changed the IDs of the filter which can
break existing sites that might rely on that filter.

In this commit we revert the ID/name change and only change the field
used. We also revert any formatting changes made to the views.* files to
make fixing merge conflicts in our search rework easier.
  • Loading branch information
Kingdutch authored and tbsiqueira committed Aug 23, 2023
1 parent c603da9 commit 5a05ee6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ processor_settings:
ignorecase:
all_fields: true
fields:
- language_with_fallback
- field_group_description
- field_group_location
- field_profile_first_name
Expand Down Expand Up @@ -332,6 +333,7 @@ processor_settings:
transliteration:
all_fields: true
fields:
- language_with_fallback
- field_group_description
- field_group_location
- field_profile_first_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,13 @@ display:
link_to_item: false
multi_separator: ', '
filters:
language_with_fallback:
id: language_with_fallback
search_api_language:
id: search_api_language
table: search_api_index_social_all
field: language_with_fallback
relationship: none
group_type: group
admin_label: ''
plugin_id: search_api_language
operator: in
value:
'***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***'
Expand Down Expand Up @@ -193,6 +192,7 @@ display:
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: search_api_language
sorts:
search_api_relevance:
id: search_api_relevance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,13 @@ display:
min: ''
max: ''
plugin_id: search_api_date
language_with_fallback:
id: language_with_fallback
search_api_language:
id: search_api_language
table: search_api_index_social_content
field: language_with_fallback
relationship: none
group_type: group
admin_label: ''
plugin_id: search_api_language
operator: in
value:
'***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***'
Expand All @@ -300,7 +299,7 @@ display:
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
operator_list: { }
identifier: ''
required: false
remember: false
Expand All @@ -318,8 +317,9 @@ display:
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
default_group_multiple: { }
group_items: { }
plugin_id: search_api_language
sorts:
search_api_relevance:
id: search_api_relevance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,13 @@ display:
group_items: { }
reduce_duplicates: false
plugin_id: search_api_options
language_with_fallback:
id: language_with_fallback
search_api_language:
id: search_api_language
table: search_api_index_social_groups
field: language_with_fallback
relationship: none
group_type: group
admin_label: ''
plugin_id: search_api_language
operator: in
value:
'***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***'
Expand All @@ -192,7 +191,7 @@ display:
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
operator_list: { }
identifier: ''
required: false
remember: false
Expand All @@ -210,8 +209,9 @@ display:
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
default_group_multiple: { }
group_items: { }
plugin_id: search_api_language
sorts:
search_api_relevance:
id: search_api_relevance
Expand Down
32 changes: 32 additions & 0 deletions modules/social_features/social_search/social_search.install
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,35 @@ function social_search_update_11402(): string {
// Output logged messages to related channel of update execution.
return $updateHelper->logger()->output();
}

/**
* Revert search_api_language filter name/id change.
*/
function social_search_update_11403() : void {
// In social_search_update_11402
// (https://github.com/goalgorilla/open_social/pull/3470/) we changed the
// search_api_language filter to a language_with_fallback filter to ensure
// that users could find matching content in different languages if no version
// in their own language was available. However, this also changed the IDs of
// the filter which can break existing sites that might rely on that filter.
// Below we go through the views and change the filter back to the ID it had,
// just with the new field added to the index.
$views = [
"views.view.search_all",
"views.view.search_content",
"views.view.search_group",
];

foreach ($views as $view) {
$config = \Drupal::configFactory()->getEditable($view);
$display = $config->get("display");

$filter = $display['default']['display_options']['filters']['language_with_fallback'];
$filter['id'] = "search_api_language";
$display['default']['display_options']['filters']["search_api_language"] = $filter;
unset($display['default']['display_options']['filters']['language_with_fallback']);

$config->set('display', $display);
$config->save(TRUE);
}
}

0 comments on commit 5a05ee6

Please sign in to comment.