field_update_field() fails if a field schema removes an index

Created on 28 July 2014, almost 10 years ago
Updated 7 August 2023, 10 months ago

I have a field type in which the schema can be edited by the user in the UI. They can add or remove columns to the field schema, which means there also may be indexes that existed in my hook_field_schema() at one point when the field is created, but later does not exist. The problem I'm experiencing is that when field_update_field() is called which should drop the old field table and re-create with the current schema, it loads the 'old' indexes from the field_read_field() stored in the database. This causes a database exception because field_sql_storage attempts to create an index on a table column that does not exist.

It seems that field_create/update_field() supports passing in additional indexes that are not defined in hook_field_schema(), which frankly seems like a very bad idea.

This will need to be verified if this also is present on Drupal 8.

πŸ› Bug report
Status

Postponed: needs info

Version

9.5

Component
FieldΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States Dave Reid Nebraska πŸ‡ΊπŸ‡Έ

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

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.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    7 years since the last comment, we'll definitely need to check if this issue still exists on 11.x, although given the length of time I'm sure all the code looks wildly different so may be hard to know.

Production build 0.69.0 2024