Problem/Motivation

The entity_usage.settings configuration saves all the available options, even when the options are not checked. This has two negative effects:

  • The entity_usage.settings are changed when no new options have been selected, when a new entity type was added since entity_usage.settings was last saved.
  • The resulting entity_usage.settings yml file is harder to read

Proposed resolution

Only save truthy values in entity_usage.settings. Compare and contrast the following configuration files:

Before:

track_enabled_base_fields: true
track_enabled_source_entity_types:
  media: media
  menu_link_content: menu_link_content
  node: node
  paragraph: paragraph
  block: '0'
  captcha_point: '0'
  comment: '0'
  comment_type: '0'
  config_split: '0'
  crop: '0'
  crop_type: '0'
  editor: '0'
  entity_browser: '0'
  facets_facet: '0'
  facets_facet_source: '0'
  facets_summary: '0'
  field_config: '0'
  field_storage_config: '0'
  file: '0'
  filter_format: '0'
  group: '0'
  group_content: '0'
  group_content_type: '0'
  group_role: '0'
  group_type: '0'
  image_style: '0'
  configurable_language: '0'
  language_content_settings: '0'
  linkit_profile: '0'
  media_type: '0'
  metatag_defaults: '0'
  node_type: '0'
  paragraphs_type: '0'
  pathauto_pattern: '0'
  poll: '0'
  poll_choice: '0'
  purl_provider: '0'
  behavior_settings: '0'
  redirect: '0'
  responsive_image_style: '0'
  rest_resource_config: '0'
  search_api_index: '0'
  search_api_server: '0'
  search_api_task: '0'
  search_api_autocomplete_search: '0'
  solr_field_type: '0'
  search_api_sorts_field: '0'
  api_key: '0'
  slick: '0'
  action: '0'
  menu: '0'
  taxonomy_term: '0'
  taxonomy_vocabulary: '0'
  ultimate_cron_job: '0'
  user_role: '0'
  user: '0'
  varnishpurgersettings: '0'
  view_mode_page_pattern: '0'
  view: '0'
  webform: '0'
  webform_options: '0'
  webform_submission: '0'
  date_format: '0'
  entity_form_display: '0'
  entity_form_mode: '0'
  entity_view_display: '0'
  entity_view_mode: '0'
  base_field_override: '0'
track_enabled_target_entity_types:
  file: file
  media: media
  node: node
  paragraph: paragraph
  block: '0'
  captcha_point: '0'
  comment: '0'
  comment_type: '0'
  config_split: '0'
  crop: '0'
  crop_type: '0'
  editor: '0'
  entity_browser: '0'
  facets_facet: '0'
  facets_facet_source: '0'
  facets_summary: '0'
  field_config: '0'
  field_storage_config: '0'
  filter_format: '0'
  group: '0'
  group_content: '0'
  group_content_type: '0'
  group_role: '0'
  group_type: '0'
  image_style: '0'
  configurable_language: '0'
  language_content_settings: '0'
  linkit_profile: '0'
  media_type: '0'
  menu_link_content: '0'
  metatag_defaults: '0'
  node_type: '0'
  paragraphs_type: '0'
  pathauto_pattern: '0'
  poll: '0'
  poll_choice: '0'
  purl_provider: '0'
  behavior_settings: '0'
  redirect: '0'
  responsive_image_style: '0'
  rest_resource_config: '0'
  search_api_index: '0'
  search_api_server: '0'
  search_api_task: '0'
  search_api_autocomplete_search: '0'
  solr_field_type: '0'
  search_api_sorts_field: '0'
  api_key: '0'
  slick: '0'
  action: '0'
  menu: '0'
  taxonomy_term: '0'
  taxonomy_vocabulary: '0'
  ultimate_cron_job: '0'
  user_role: '0'
  user: '0'
  varnishpurgersettings: '0'
  view_mode_page_pattern: '0'
  view: '0'
  webform: '0'
  webform_options: '0'
  webform_submission: '0'
  date_format: '0'
  entity_form_display: '0'
  entity_form_mode: '0'
  entity_view_display: '0'
  entity_view_mode: '0'
  base_field_override: '0'
track_enabled_plugins:
  entity_reference: entity_reference
  html_link: html_link
  link: link
  linkit: linkit
  block_field: '0'
  entity_embed: '0'
local_task_enabled_entity_types:
  comment: '0'
  entity_browser: '0'
  facets_facet_source: '0'
  file: '0'
  group: '0'
  group_content: '0'
  media: '0'
  menu_link_content: '0'
  node: '0'
  poll: '0'
  redirect: '0'
  search_api_index: '0'
  search_api_server: '0'
  taxonomy_term: '0'
  user: '0'
  webform: '0'
  webform_submission: '0'
site_domains: {  }

After:

track_enabled_base_fields: true
local_task_enabled_entity_types:
  - media
track_enabled_source_entity_types:
  - media
  - menu_link_content
  - node
  - paragraph
track_enabled_target_entity_types:
  - file
  - media
  - node
  - paragraph
track_enabled_plugins:
  - entity_reference
  - html_link
  - link
  - linkit
site_domains: {  }

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

idebr created an issue. See original summary.

idebr’s picture

Issue summary: View changes
idebr’s picture

Issue summary: View changes
idebr’s picture

Issue summary: View changes
idebr’s picture

Status: Active » Needs review
StatusFileSize
new6.79 KB

Attached patch updates EntityUsageSettingsForm::submitForm so it saves only truthy values in entity_usage.settings

The updated format in entity_usage.settings is backwards compatible with the current configuration values, since the values are unchanged.

Status: Needs review » Needs work

The last submitted patch, 5: entity_usage-truthy_values-2981200-5.patch, failed testing. View results

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.92 KB
new6.49 KB

Let's go with the smallest change possible.

  • marcoscano committed 4f9224b on 8.x-2.x authored by idebr
    Issue #2981200 by idebr, marcoscano: Only save truthy values in...
marcoscano’s picture

Status: Needs review » Fixed

Fixed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.