By submitting patches for review, you agree to the Developer Certificate of Origin. A copy of this agreement can be found in the project root, named CONTRIBUTING.txt.
Problem/Motivation
When enabling translation for a content type, the following exception is produced:
TypeError: Drupal\Core\Entity\EntityBase::getOriginal(): Return value must be of type ?Drupal\cached_moderation_state\HiddenFieldConfig, Drupal\field\Entity\FieldConfig returned in Drupal\Core\Entity\EntityBase->getOriginal() (line 697 of /app/web/core/lib/Drupal/Core/Entity/EntityBase.php).
#0 /app/web/modules/contrib/cached_moderation_state/src/HiddenFieldConfig.php(27): Drupal\Core\Entity\EntityBase->getOriginal()
#1 /app/web/core/modules/field/src/Entity/FieldConfig.php(182): Drupal\cached_moderation_state\HiddenFieldConfig->getOriginal()
#2 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(567): Drupal\field\Entity\FieldConfig->preSave(Object(Drupal\field\FieldConfigStorage))
#3 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(522): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\cached_moderation_state\HiddenFieldConfig))
#4 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(239): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\cached_moderation_state\HiddenFieldConfig))
#5 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(370): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\cached_moderation_state\HiddenFieldConfig))
#6 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(635): Drupal\Core\Entity\EntityBase->save()
Steps to reproduce
// Load some moderated entity.
$entity = \Drupal\node\Entity\Node::load(1);
// Attempt to update the cached_moderation_state field definition.
$field_definition = $entity->getFieldDefinition('cached_moderation_state');
$field_definition->save();
Proposed resolution
Override the definition of EntityBase::setOriginal() to always convert the original entity to the static type.
Issue fork cached_moderation_state-3578590
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
clayfreeman