0

I am using Drupal 8.05

I am unable to add a new user. I get the following error when I press "Add User" button:

Drupal\Core\Entity\Query\QueryException: 'field_housing_coop_ref' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 252 of core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).

'field_housing_coop_ref' was an entity reference field (pointing to Content Type A) on Content Type B. I deleted the 'field_housing_coop_ref' field and get the error.

If I recreate the field then I can add a new user. When I delete the field I get the error again.

I put this on the Drupal core issues list as support request but it got closed as not a reproducible error. So it seems to be something particular to my site.

Currently I have the field existing but unused and hidden on the form/display modes. Any idea about what I have done and how I might better resolve this much appreciated.

  • Have you done any customization in your site, which might be related to this & might have affected. Something similar has happened in my test Drupal8 instance. There was entity reference field I've created for testing what else I can use as entity reference & used contact form as ref. I deleted that field few days back, but some of the ref of that field are still available in db. Now when I'm adding field there are no errors but when I delete any field in any entity I get error. When I check db I always find some ref in key_value table. You can check if there are any ref in your db as well – Yogesh Mar 19 '16 at 18:44
  • I did a search and a record holding the deleted field name does indeed exist in the key_value table (in record with collection=entity_autocomplete). I presume it would be foolhardy to simply delete the record? – Polly Mar 20 '16 at 20:27
  • Try if this helps fix issue, make sure to take a backup of db before doing this. Delete all matching record for that field in key_value table and then rebuild cache. – Yogesh Mar 21 '16 at 8:56
  • I took a slightly different route.The deleted field actually appeared in several places. In the key-value table, in some cache tables and in table rows which also referenced other fields which were also a Drupal ContentTypeA reference field. So, I deleted the other field that was a ContentTypeA reference via the Drupal interface. I then deleted the key_value & cache rows via PHPMy Admin. And everything seems to be working fine. I had to put back the ContentTypeA reference I want to keep and rebuild a couple of views but problem solved. Thanks for pointing me in right direction. – Polly Mar 22 '16 at 18:49
  • I am not entirely sure of the etiquette. Perhaps we should actually write this as an answer. Do you want to do that? If not I am happy to do it. – Polly Mar 22 '16 at 18:56
1

NOTE:Make sure to take backup of database before doing below changes to avoid any issues.

Search for "field_housing_coop_ref" field in entire database including cache tables, mostly cache_* and key_value tables. Once you've all matching records with you, delete one by one very carefully by reading there names properly to make sure nothing else get deleted.

Once you've deleted matching records for "field_housing_coop_ref" field, rebuild cache by navigating to "Admin => Configuration => Development => Performance" or using Drush command "drush cr".

Updates:

If there are any other references for this field inside other fields in key_value table, make sure to delete those field from Field UI and then cross verify again.

  • I actually performed one additional step. In the db 'field_housing_coop_ref' was also referenced in a row for another field which was also a reference to the same content type. I deleted this other field via the Drupal interface (and put it back via Drupal at the end of the whole process - a pain but surer than deleting db rows which referenced existing fields). – Polly Mar 24 '16 at 11:10
  • Thanks @Polly for improvements. I've added that under updates section. – Yogesh Mar 24 '16 at 11:43

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.