3

I have a message in the /admin/reports/status page regarding some fields.

FYI, those are custom fields that I have deleted

Here is the message:

The %field_name field needs to be uninstalled.

To solve this, I ran cron, I drush cr and finally drush entup =>but this last step display the following error:

In DiscoveryTrait.php line 52: The "field_item:mwd" plugin does not exist. 

mwd is the id of custom field type for which there is a message in the status page...

Here is the Plugin definition and the Class definition of this custom field

 * @FieldType(
 *   id = "mwd",
 *   label = @Translation("Days of week in a Month for a user"),
 *   description = @Translation("Store all days of week in a month for a user."),
 *   category = @Translation("Calendar"),
 *   default_formatter = "mwd_ds_formatter",
 *   default_widget = "mwd_ds_widget",
 * )
 */
class MWDItem extends FieldItemBase implements FieldItemInterface{...

I have created an instance of this field type (with the GUI of drupal) and added it to a content type. This is this field which needs to be uninstalled if I conforms to the status page message.

Unfortunately I can't get rid of it: impossible to remove this warning in the /admin/reports/status page

16
  • The deleted field was a configured field?
    – 4uk4
    Commented Jan 10, 2019 at 13:21
  • I have updated my post to explain from where this field is coming from. If I understand well, this is a configured field as it has been created with the GUI of drupal and added to a content type.
    – Baud
    Commented Jan 10, 2019 at 14:57
  • Yes, this is a configured field. Normally it's no problem to delete a field from a content type. But in your case the delete process couldn't be completed because the field plugin is missing. I don't know how you managed to do this. There should be a warning when you try to uninstall a field module if it still has dependencies in config.
    – 4uk4
    Commented Jan 10, 2019 at 15:18
  • I have to say that the field plugin is not missing... I have added a bug issue there: drupal.org/project/drupal/issues/3023054 I really don't know what to do.
    – Baud
    Commented Jan 10, 2019 at 16:05
  • The error message clearly says the plugin is missing. You can list all field type plugins with the Drupal Console command drupal debug:plugin field.field_type.
    – 4uk4
    Commented Jan 10, 2019 at 16:26

2 Answers 2

3

Here is a snippet which you could use in hook_update or drush php context. However it will only work if the tables are still there - while this is rare, it can happen - you're in this situation because something didn't happen correctly, so expect the unexpected.

$manager = \Drupal::entityDefinitionUpdateManager();
$definition = $manager->getFieldStorageDefinition("field_blah", "node");
$manager->uninstallFieldStorageDefinition($definition);

It the tables do not exist then the field cannot be programmatically uninstalled, as Drupal will try to query them. In this case, adding and removing the field through the UI is the easiest way, per other answers.

1

I had the same problem with a custom field. I solved it by creating the broken field in the UI once again and deleting it afterwards: The error went away. Just take care of the name of the field (without the string "field_" at the beginning).

1
  • I had this after deleting some unwanted Paragraph Types. The fixes that use drush entup all failed because the field had been deleted so the table in the database didn't exist. Creating another field of the same name in the same entity type e.g. a paragraph, and deleting it purges the message.
    – Timmah
    Commented Jun 22, 2023 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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