Skip to content

Commit

Permalink
Fix view name for groups search
Browse files Browse the repository at this point in the history
We can't just fix the change in `social_search_update_11403` because we
would leave sites that had already executed the update in an
indeterminate state.

There's two scenarios:

1) The update has already run. In this case the change for the groups
view hasn't happened due to the type, the new update hook will be
executed and now all views are correct.

2) The update hook hasn't run already. In this case we do the correct 2
views (that sites from scenario 1 don't need help changing) in 11403 and
we fix groups in 11404.
  • Loading branch information
Kingdutch authored and tbsiqueira committed Aug 29, 2023
1 parent aa48f60 commit 4c893b7
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion modules/social_features/social_search/social_search.install
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ function social_search_update_11403() : void {
$views = [
"views.view.search_all",
"views.view.search_content",
"views.view.search_group",
];

foreach ($views as $view) {
Expand All @@ -323,3 +322,33 @@ function social_search_update_11403() : void {
$config->save(TRUE);
}
}

/**
* Revert search_api_language filter name/id change for groups view.
*/
function social_search_update_11404() : void {
// There was a typo in the view name of social_search_update_11403 which
// caused the groups view not to be updated, so we must do it again here.
$views = [
"views.view.search_groups",
];

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);
}

// Clean up the config created in our erroneous version of 11403.
$incorrect_view = \Drupal::configFactory()->getEditable("views.view.search_group");
if (!$incorrect_view->isNew()) {
$incorrect_view->delete();
}
}

0 comments on commit 4c893b7

Please sign in to comment.