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.

Comments

andy_w created an issue. See original summary.

andy_w’s picture

Status: Active » Needs review
StatusFileSize
new1.31 KB

Patch created to check for EntityInterface in use.

kentr’s picture

Status: Needs review » Reviewed & tested by the community

#2 worked for me to eliminate the fatal error.

The body field isn't cloning for me, but maybe that's another issue.

karthikeyan-manivasagam’s picture

Fields are not getting created I use paragraph fields, text area, checkbox

karthikeyan-manivasagam’s picture

Status: Reviewed & tested by the community » Needs work
karthikeyan-manivasagam’s picture

Please the find the patch which is created with entity reference class and confirming its working fine

karthikeyan-manivasagam’s picture

Status: Needs work » Needs review
alex.skrypnyk’s picture

Status: Needs review » Reviewed & tested by the community

#6 works as expected. Thank you! RTBC

andyf’s picture

+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.

lukus’s picture

Works for me too, thx

eworwa’s picture

Patch in #9 worked for me.

vuil’s picture

Version: 8.x-1.3 » 8.x-1.x-dev

  • vuil committed 714bbc7 on 8.x-1.x authored by AndyF
    Issue #3053633 by karthikeyan-manivasagam, andy_w, AndyF, vuil: Issue...
vuil’s picture

Status: Reviewed & tested by the community » Fixed

It was already committed into the latest 8.x-1.x-dev branch.
I close the issue as Fixed.
Thanks to everyone.

Status: Fixed » Closed (fixed)

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