[migrate_upgrade compatibility] d7_field_instance upgrade fails due to redundant 'field_' prefix removal on bundle

Created on 15 January 2021, over 3 years ago
Updated 28 January 2024, 8 months ago

Problem/Motivation

When trying to migrate a D7 site with field_collections to D8, sometimes field instances fail to migrate because the process pipelines remap the bundle names incorrectly. For instance, a D7 field_collection named 'field_my_field_collection' should map to the paragraphs bundle 'my_field_collection', but when processing certain field instance rows, it may become 'ld_collection' instead (removing 12 characters instead of only 6), and yield an error like 'Missing bundle entity, entity type paragraphs_type, entity id ld_collection' (or a couple other variations).

Steps to reproduce

I'm not sure how to reproduce this, other than a specific site, but other users have had similar reports. It may be that a combination of field_collection, field_group, and possibly sharing field instances of the same base field (of type field collection) trigger the issue.

See https://www.drupal.org/project/paragraphs/issues/2897021#comment-12491141 for instance, although significant progress has been made since then.

Proposed resolution

Currently, the MigrationPluginsAlterer class iterates over process pipelines and adds a substr plugin. I could not fully comprehend this with my level of comfort on both paragraphs and the whole migration framework, so there is almost certainly a deeper issue that my proposed solution won't address.

I made a slight variation of the substr plugin, which checks that the string actually begins with 'field_' before returning it, and returns the input as-is if it doesn't start with the proper prefix.

This clearly isn't a perfect solution, as it could still have failure cases if someone had named their field collection 'field_field_something', but did fix the issue for my site.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States noahadler

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India Ali Rizvi

    hi,
    I'm migrating d7 to d9 and i have to migrate field collections to paragraphs and in field collections i have fields which has field type 'entity reference' and that reference's to field collection and view of field collection

    drush mim upgrade_d7_field_collection_type
    This creates the Paragraph Types from Field Collection

    drush mim upgrade_d7_field_collection_field_name
    This creates field instance ONLY

    drush mim upgrade_d7_node_type
    "Imports node types, This creates the Content Types - CCK structure"

    and when i try to import field of cck using this
    drush mim upgrade_d7_field

    33/107 [========>-------------------] 30% [error] The "field_collection_item" entity type does not exist. (/opt/httpd/htdocs/sites/vecplerpd9/master/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php:139)
    [error] The "field_collection_item" entity type does not exist.
    [notice] Processed 107 items (101 created, 0 updated, 6 failed, 0 ignored) - done with 'upgrade_d7_field'

    cck fields are not getting migrated because of field collections

    any help would be appreciated

  • 🇺🇸United States alison

    #5 fixed the issue for me (PHEW).

  • Status changed to Fixed 9 months ago
  • 🇨🇭Switzerland berdir Switzerland

    Looks like it works for several people but others still have issues. Committed this, if you still have issues then open a new issue (see also comment #23).

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

Production build 0.71.5 2024