Problem/Motivation

When a config entity that represents a bundle is cloned, the module also clones any fields and view/form displays.
For a large number of fields, this can lead to timeouts.

Proposed resolution

Use the batch API to create the fields.

Remaining tasks

Patch
Tests
Review

User interface changes

None

API changes

None

Data model changes

None

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Assigned: Unassigned » larowlan

giddyup

larowlan’s picture

This works for me

Status: Needs review » Needs work

The last submitted patch, 3: entity-clone-batch-2845094.patch, failed testing.

jibran’s picture

Code looks good.
We should add some tests.
Just a minor suggestion.

+++ b/src/EntityClone/Config/ConfigWithFieldEntityClone.php
@@ -83,21 +88,120 @@ class ConfigWithFieldEntityClone extends ConfigEntityCloneBase {
+  public static function batchCloneField($cloned_entity_id, FieldDefinitionInterface $field_definition, $entity_type_id, array &$context) {
...
+  public static function batchCloneDisplay($type, $entity_id, $cloned_entity_id, $bundle_of, $view_display_id, $entity_type_id, array &$context) {
...
+  public static function batchCloneFinished() {

Do you think it is a good idea to move these to a new class with clone helpers?

mikejw’s picture

Just tried this out - works great! I had to add in eform_type to the list (will supply a patch soon) but all good after that.

colan’s picture

Assigned: larowlan » Unassigned

I was going to rerun the tests now that the branch is passing, but this is NW based on the above comments so leaving as-is.

larowlan’s picture

Status: Needs work » Needs review
FileSize
10.13 KB

re-roll

dpi made their first commit to this issue’s fork.

dpi’s picture

Re-rolled after conflicts from #3190160: Entity view displays with layouts are cloned incorrectly and pushed as MR.