Similar to the issue around taxonomy parent terms not successfully being duplicated, the content moderation 'moderation_state' field will not successfully clone, as it has the target bundle method but does not actually implement the EntityInterface. So we just need to check that it does actually implement the interface ahead of using the createDuplicate method.
Then this seems to behave correctly.
Steps to replicate
1. Create a site with Entity Type Clone & Content Moderation enabled
2. Enable content moderation on the content type
3. Clone the content type
Expected outcome
The entity type is cloned correctly
Actual outcome
An error is thrown
Error: Call to undefined method Drupal\Core\Field\BaseFieldDefinition::createDuplicate() in Drupal\entity_type_clone\Form\CloneEntityTypeData::cloneEntityTypeField() (line 30 of /var/www/html/docroot/modules/contrib/entity_type_clone/src/Form/CloneEntityTypeData.php).
And an empty content type (no fields or display settings) of the name specified is created.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3053633-moderation-state-field-giving-create-duplicate-error-9.patch | 1.5 KB | andyf |
| #2 | 3053633-moderation-state-field-giving-create-duplicate-error.patch | 1.31 KB | andy_w |
Comments
Comment #2
andy_w commentedPatch created to check for EntityInterface in use.
Comment #3
kentr commented#2 worked for me to eliminate the fatal error.
The
bodyfield isn't cloning for me, but maybe that's another issue.Comment #4
karthikeyan-manivasagam commentedFields are not getting created I use paragraph fields, text area, checkbox
Comment #5
karthikeyan-manivasagam commentedComment #6
karthikeyan-manivasagam commentedPlease the find the patch which is created with entity reference class and confirming its working fine
Comment #7
karthikeyan-manivasagam commentedComment #8
alex.skrypnyk#6 works as expected. Thank you! RTBC
Comment #9
andyf commented+1 thanks! This fixed the error and so far the clone seems to have worked correctly. However it looks like the patch in #6 is in UTF16. I've converted it to UTF-8.
Comment #10
lukusWorks for me too, thx
Comment #11
eworwa commentedPatch in #9 worked for me.
Comment #12
vuilComment #14
vuilIt was already committed into the latest 8.x-1.x-dev branch.
I close the issue as Fixed.
Thanks to everyone.