0

After deleting some fields and paragraph types, I have stale values in the entity field map - these cause notice-level errors in the /admin/reports/fields page, and seem to occasionally trigger weird exceptions.

I've tracked the stale data to entity.definitions.bundle_field_map entries in the {key_value} table. Unfortunately, neither running cron nor synchronizing the configuration nor clearing the cache seems to update this.

I've deleted the entries from the table entirely, but they just stay gone. Is there a way to completely rebuild the map from the active configuration?


Update: For future reference, this problem (and similar entity schema corruption) was a likely consequence of mucking around with unalterable internals (type, machine name, etc) of existing fields. Never do that; this system is complex, easy to break, and basically impossible to get back into a consistent state without reinstalling or reverting to backup.

Any changes to the storage of a field should be done by creating a new field, copying data, and deleting the old field. Even if you want to retain the existing machine name, it is easier to follow these steps twice (using a temporary field) than to try to touch the internals.

(Also, some aspects of the schema seem to be updated by cron, so before reusing a deleted field's machine name, make sure to run cron to let it perform cleanup.)

  • I'm not sure I understand the issue but maybe try running drush entup -y – user21641 Jun 1 '17 at 11:29
  • How did you delete those things? The logic to remove keys from it is in \Drupal\Core\Field\FieldDefinitionListener::onFieldDefinitionDelete(), you might be able to run that for your specific field names by hand. – Berdir Jun 1 '17 at 17:03
0

Update: It seems this data is never rebuilt in full, but is only updated by a field definition listener.

One possible solution is to remove all fields and bundles from the site (by deleting the configuration from the sync folder and importing), then re-creating them (by reverting the deletions and importing again). This will obviously delete any content that may have been created.

  • I fixed this by editing the key_value table value with the field mapping. Then clearing cache and it worked. – Johan Haest Dec 4 '17 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.