Commit 4867a38f authored by Nia Kathoni's avatar Nia Kathoni Committed by Daniel Cothran
Browse files

Issue #3310145 by nikathone: Fix...

Issue #3310145 by nikathone: Fix charts_post_update_migrate_library_default_settings_to_library_config wrong new key name
parent 69f24d9d
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -69,9 +69,24 @@ function charts_post_update_migrate_library_default_settings_to_library_config(&
    if ($library_id) {
      $old_key = 'charts_default_settings.' . $library_id . '_settings';
      $library_config = $config->get($old_key);
      $config->set('library_config', $library_config);
      $config->set('charts_default_settings.library_config', $library_config);
      $config->clear($old_key);
      $config->save();
    }
  }
}

/**
 * Clear library_config set on the wrong place. See drupal.org/i/3310145.
 */
function charts_post_update_clear_library_config_key_added_on_wrong_place(&$sandbox) {
  /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
  $config_factory = \Drupal::service('config.factory');
  $config = $config_factory->getEditable('charts.settings');
  if ($config && $config->get('library_config')) {
    // Not to be confused with "charts_default_settings.library_config" which is
    // the proper key.
    $config->clear('library_config');
    $config->save();
  }
}