technonaturalist

image link to hive image link to ko-fi

Drupal 7 notes - dealing with "ghost fields"

posted on: Wednesday, 12 January 2011 @ 11:34pm in
tagged

Came across a problem someone else on Drupal dubbed “ghost field” in one of the issue queues. My issue with ghost fields came about while setting up Profile2 to use in my profile (strangely), but the problem happens in other modules as well.

The problem

  1. create a profile type (or modify the main one)
  2. add a field
  3. delete the field (I don’t recall seeing any difference between saving data in the field or not)
  4. try to add a new field with the same name, get an error saying the field name is already in use, but it doesn’t appear in the “Add existing field” list

The solution

  1. manually edit the database. I use phpmyadmin. Whatever works
  2. find the tables field_config and field_config_instance, browse them and delete all incidences of the “ghost fields”
  3. fields can now be recreated

After deleting the ghost field instances the php fatal error and associated debug messages I’d been having trouble tracking the source of (Entity was getting blamed) disappeared, quite conveniently.