After migration from wbm 2 content moderation when I click on node edit I am getting ModerationStateFieldItemList::referencedEntities() not found error.

Error: Call to undefined method Drupal\\content_moderation\\Plugin\\Field\\ModerationStateFieldItemList::referencedEntities() in /Users/kumsu25/Sites/devdesktop/docops-upgradedbase/docroot/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php on line 88 #0 docops-upgradedbase/docroot/core/lib/Drupal/Core/Field/WidgetBase.php(322): Drupal\\Core\\Field\\Plugin\\Field\\FieldWidget\\EntityReferenceAutocompleteWidget->formElement(Object(Drupal\\content_moderation\\Plugin\\Field\\ModerationStateFieldItemList), 0, Array, Array, Object(Drupal\\Core\\Form\\FormState)), referer: https://docops-upgradedbase.dd:8443/de-de/node-1597-integrations

drupal version : 8.4.3 has

class ModerationStateFieldItemList extends FieldItemList {

}

drupal version : 8.2.x has

class ModerationStateFieldItemList extends EntityReferenceFieldItemList {

}

I got error in drupal version : 8.4.3 .

When I try to access /admin/structure/types/manage/story/form-display

stderr: Uncaught PHP Exception Drupal\\Component\\Plugin\\Exception\\PluginNotFoundException: "The "" entity type does not exist." at /Users/kumsu25/Sites/devdesktop/docops-upgradedbase/docroot/core/lib/Drupal/Core/Entity/EntityTypeManager.php line 133.

Comments

suresh kumara created an issue. See original summary.

flutterstack’s picture

Issue summary: View changes
flutterstack’s picture

Issue summary: View changes
david.gil’s picture

same here.

jmoreira’s picture

I am also having this issue when creating new content types and blocks that don't need to be moderated. This seems happen because the class Drupal\content_moderation\EntityTypeInfo adds the moderation state field to all entities that can be moderated regardless if selection for moderation for an specific bundle(see function entityBaseFieldInfo). I would gladly work on a patch but I'm not sure what the best solution would be.

An intermediary solution that got my site working again was to delete all the config files for the bundles I don't want moderation on and run drush cim.

Example:

  • rm path/to/config/core.base_field_override.ENTITY_TYPE.ENTITY_BUNDLE.moderation_state.yml
  • drush cim
nikunjkotecha’s picture

Version: 8.x-2.0-alpha3 » 8.x-2.x-dev
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new1.46 KB

Thanks for the findings @jmoreira.

I had to do one more step to ensure it works fine (since we were not using full config import / export). Added the code in drush command itself.

nikunjkotecha’s picture

StatusFileSize
new1.8 KB

Updated patch to handle exceptions for entity types not supporting base field definitions call.

phenaproxima’s picture

Status: Needs review » Needs work

Great catch, great patch! I want to merge it, but I can't do that until this change is also implemented in the Drush 9 variant of the command. Additionally, this will need tests.

phenaproxima’s picture

Issue tags: +Needs tests
phenaproxima’s picture

StatusFileSize
new5.64 KB

Refactored the patch to work with Drush 9 and Drush 8. It will also delete the base field overrides *before* installing Content Moderation, not afterwards. If anyone can give this a quick manual test, it would be heavily appreciated!

lahoosascoots’s picture

Works great only if all entity types are fieldable. To account for non-fieldable we can pop this at line 161 of MigrationController

$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
  continue;
}

  • 509325e committed on 8.x-2.x
    Issue #2933745 by nikunjkotecha, phenaproxima, lahoosascoots: After...
phenaproxima’s picture

Status: Needs work » Fixed

Committed and pushed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.