You are here

function search_api_solr_update_8304 in Search API Solr 8.3

Same name and namespace in other branches
  1. 4.x search_api_solr.install \search_api_solr_update_8304()

Convert site_hash from setting to state.

File

./search_api_solr.install, line 915
Install, update and uninstall functions for the Search API Solr module.

Code

function search_api_solr_update_8304() {
  $config_factory = \Drupal::configFactory();
  $settings = $config_factory
    ->getEditable('search_api_solr.settings');
  \Drupal::state()
    ->set('search_api_solr.site_hash', $settings
    ->get('site_hash') ?? '');
  $settings
    ->delete();
  foreach ($config_factory
    ->listAll('search_api.server.') as $server_name) {
    $server = $config_factory
      ->getEditable($server_name);
    $backend_config = $server
      ->get('backend_config');
    $backend_config['optimize'] = FALSE;
    $server
      ->set('backend_config', $backend_config)
      ->save(TRUE);
  }
}