Created on 10 November 2022, about 2 years ago
Updated 24 April 2024, 8 months ago

Problem/Motivation

Using a configuration inspector module seeing errors everywhere this module is used for missing schema, which is used for translations also.

Steps to reproduce

Enable module
Install configuration inspector
Go to the view and see the error
third_party_settings.entity_usage_light.entity_type_ids Undefined undefined missing schema
third_party_settings.entity_usage_light.entity_type_views Undefined undefined missing

Proposed resolution

Add schema

Remaining tasks

Write schema
Review
commit

User interface changes

NA

API changes

NA

Data model changes

NA

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States smustgrave

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    I think it needs to be a string. When entityTypeAlter() is called, it uses array_filter() on the active_on array, which returns an array of the values. So that needs to be the entity type, not a boolean.

    Also, the settings form wasn't saving correctly because it didn't account for the active_on key. I fixed this in the last commit, so it is now:

        foreach ($form_state->getValues()['active_on'] as $key => $data) {
          if (!in_array($key, $exclude)) {
            $config->set("active_on.$key", $data);
          }
    

    The config needs to match the format used to build the checkboxes:

        $active_on_default_value = $config->get('active_on') ?? (in_array('node', array_keys($entity_types)) ? ['node' => 'node'] : []);
        ...
        '#options' => array_combine(array_keys($entity_types), array_keys($entity_types)),
        '#default_value' => $active_on_default_value,
    

    Config gets stored as:

    active_on:
      node: node
      block_content: '0'
      code_sample: '0'
      comment: '0'
      contact_message: '0'
      file: '0'
      media: media
      menu_link_content: '0'
      path_alias: '0'
      shortcut: '0'
      taxonomy_term: '0'
      user: '0'
      paragraph: '0'

    I think it would make more sense to just store the entity type for active entities, and not include user: '0'. That would look like:

    active_on:
      - node
      - block_content

    This is how it's done in the book module, the schema and settings form are good references.

  • Thank you very much once again for your contributions.

    I agree the setting values are not ideally formatted.

    I have updated entity_usage_light.settings and {entity_type}.{bundle}.third_party.entity_usage_light.entity_type_ids value lists in this commit.

    The config inspector does not return errors anymore.

    Keeping this issue as Needs Review because we need to confirm the hook_update_891001() works correctly and that we are happy with the schema and configurations.

  • Status changed to Needs work 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Probably could look into some validation now that that has taken off.

  • Status changed to Fixed 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Marked the sequence as validatable so all schema is good :)

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

Production build 0.71.5 2024