Unable to determine class for field Drupal 8

Posted on: Fri, 05/01/2020 - 14:08 By: Arun AK

Drupal is a popular and best content management system. Even it is more powerful, and sometimes we have to deal with a tough time if we are not maintaining it well.

Here we see one of the issues that can happen in Drupal 8 if we do not correctly uninstall module before it removes from the file system. Your site might be working correctly on the production server, and the issues can arise after you move your site into a new server or after setup your local dev environment.

Here we take an example of one of the issues related to the simplenews module. The scenario is we are receiving following error on the website:

RuntimeException: Unable to determine class for field type 'webform' found in the 'field.storage.node.simplenews_issue' configuration..

But we cannot see 'drupal/simplenews' module either on the 'composer.josn' or file system. As the first solution that comes in mind is, we will add the module using the composer to the file system and then uninstall it properly. But here is the problem, suppose if the module (here it is 'simplenews') is already there in 'core.extension' the configuration, you cannot enable the module again. Also, if the related settings exist in the database, it will be challenging to enable the module again.

So in this situation, what you can do is you could manually remove the problem making configurations from the database. Here in this case we need to remove 'field.storage.node.webform'. So you could use the following SQL query to remove the settings from the database.

DELETE FROM config WHERE name = 'field.storage.node.simplenews_issue' OR data LIKE '%field.storage.node.simplenews_issue%'

You can run the query using a MySQL client or using drush as below:

drush sqlq "DELETE FROM config WHERE name = 'field.storage.node.simplenews_issue' OR data LIKE '%field.storage.node.simplenews_issue%'"

Then clear the cache Drupal using admin UI or 'drush cr'. It will resolve the issue.