Changing the indexes of field storage with non revision entity is broken

Created on 31 October 2017, about 7 years ago
Updated 9 November 2023, about 1 year ago

Problem/Motivation

SqlContentEntityStorageSchema::updateDedicatedTableSchema() is broken when the entity type doesn't support revision.

The error message is:

TypeError: Argument 4 passed to Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::addIndex() must be of the type array, null given, called in /Project/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php on line 1388 in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->addIndex() (line 2102 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

I use the config_devel to update the field config file automatically. To adding indexes in field table, I add an item indexes into field.storage.registrant.field_my_field.yml. It looks like:

langcode: zh-hant
status: true
dependencies:
  module:
    - rng
id: registrant.field_my_field
field_name: field_my_field
entity_type: registrant
type: string
settings:
  max_length: 255
  is_ascii: false
  case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes:
  value:
    - value
persist_with_no_fields: false
custom_storage: false

Set the config file importing automatically in config_devel. I expect config_devel will import the config and add value (field_register_code_value) field as index in field_my_field database table. However, when the index is added or dropped, it will throw an exception as above.

Proposed resolution

Check if the entity type support revision or not.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Field 

Last updated 2 days ago

Created by

🇹🇼Taiwan johnhuang0808

Live updates comments and jobs are added and updated live.
  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

Production build 0.71.5 2024