Cloning to other entity type bundles should not be allowed, until it's supported

Created on 28 February 2023, about 2 years ago
Updated 28 May 2024, 10 months ago

Problem/Motivation

See Move fields from one entity to another Closed: won't fix for details. As it seems, the module allows to clone fields to other content types, but doesn't implement cloning the field storages over. This may lead to unexpected results and should be preserved, until it is supported.

Steps to reproduce

Proposed resolution

Hide other entity bundles in the form at admin/structure/{ENTITY-TYPE}/{BUNDLE}/fields/tools/clone-fields and only allow to clone to bundles of the same entity type.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    From https://www.drupal.org/project/field_tools/issues/1349646#comment-14945075: Move fields from one entity to another Closed: won't fix

    > It's quite dangerous, if someone clones a field across entity types currently, isn't it?
    I suggest only showing current entities fields, until this is properly implemented

    It should be fine, but you have to:

    a. check the field name isn't already used on the destination entity type
    b. clone the field storage as well as the instances

  • 🇩🇪Germany Anybody Porta Westfalica

    Note to myself: Before starting here, check what exactly happens currently (cex --diff) when cloning to a different entity bundle!

  • 🇬🇧United Kingdom joachim

    Can you check the module first to see how much of this is already done?

    The comments and code in FieldCloner make it look like this is already handled in part:

       * @param string $destination_entity_type_id
       *  The entity type to clone the field to. If this is different from the
       *  source field, then one of the following will happen:
       *    - a) a new field storage is created
       *    - b) an existing field storage is used, if its type matches the source
       *      field.
       *    - c) an exception is thrown if the existing type does not match.
    
  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks @joachim JEP I'll do that, also see #5. This is on our plan, but I can't yet tell when we can do it. But we will :)

    If someone is faster, I'd also be happy, of course!

  • Status changed to Closed: cannot reproduce 10 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks @joachim indeed I can not reproduces the issues anymore. I think it was fixed in the meantime. Works great, even X entity type! :)

Production build 0.71.5 2024