Problem/Motivation

The following error occurs on `drush ms` when there is a non-bundleable entity type (in this case Linkback):

InvalidArgumentException: A bundle was provided but the entity type (linkback) is not bundleable. in                                                                                     [error]
/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php:112
Stack trace:
#0 /core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php(133): Drupal\migrate_drupal\Plugin\migrate\source\ContentEntity->__construct(Array,
'content_entity:...', Array, Object(Drupal\migrate\Plugin\Migration), Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Entity\EntityFieldManager),
Object(Drupal\Core\Entity\EntityTypeBundleInfo))
#1 /core/modules/migrate/src/Plugin/MigratePluginManager.php(57):
Drupal\migrate_drupal\Plugin\migrate\source\ContentEntity::create(Object(Drupal\Core\DependencyInjection\Container), Array, 'content_entity:...', Array,
Object(Drupal\migrate\Plugin\Migration))
...

This is caused by the migration d6_entity_reference_translation calling EntityReferenceTranslationDeriver::getDerivativeDefinitions() and setting 'bundle' in the migration source.

Proposed resolution

Check if the entity type has bundles.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RumyanaRuseva created an issue. See original summary.

RumyanaRuseva’s picture

Status: Active » Needs review
FileSize
2.08 KB

Here is a patch.

captainpants’s picture

This is also an issue when migrating from D7 to D8 sites. Patch #2 works like a charm.

captainpants’s picture

Status: Needs review » Reviewed & tested by the community
heddn’s picture

Status: Reviewed & tested by the community » Needs work

I think this needs a test. So back to NW. Great find by the way.

RumyanaRuseva’s picture

Issue tags: +Needs tests
mpp’s picture

Title: Migration d6_entity_reference_translation fails to create instance when non-bundleable entity type exists. » Migration fails to create instance when non-bundleable entity type exists.

The patch in 2 also fixes the problem for migrations towards custom entities without a bundle:

destination:
  plugin: 'entity:mycustom'

[error] A bundle was provided but the entity type (mycustom) is not bundleable.

maxocub’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.59 KB
3.67 KB

For a failing test I just added an entity reference field on the non-bundleable entity user.
The test only patch is the interdiff.

The last submitted patch, 8: 2981225-8-test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 8: 2981225-8.patch, failed testing. View results

maxocub’s picture

Updated the entity count to fix the test.

The last submitted patch, 11: 2981225-11-test-only.patch, failed testing. View results

mpp’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, marking as rtbc.

  • alexpott committed 68c7b00 on 8.7.x
    Issue #2981225 by maxocub, RumyanaRuseva, mpp: Migration fails to create...

  • alexpott committed 8455641 on 8.6.x
    Issue #2981225 by maxocub, RumyanaRuseva, mpp: Migration fails to create...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Credited @mpp for a review confirming this fixes custom non-bundleable entity type migrations.

Committed to 8.6.x and 8.7.x. Thanks!

Status: Fixed » Closed (fixed)

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

marvil07’s picture

Commenting just to mention that the patch at #11 applies to 8.5.x too, at least on 8.5.6.

I am getting the same problem in 8.5.x, in my case related to d7_entity_reference_translation migration.

Not re-opening the issue, since I guess alexpott had a reason to not add the patch to 8.5.x.

vijaycs85’s picture

#18++