Problem/Motivation

This error appears when running the d6_node_setting_promote migration when the bundle already exists. I just had it now while refactoring our dumps in #2348875: Improving our dump files but i've also seen it when migrating a Drupal 6 to Drupal 8 site with the two content types that come from the Standard install profile.

base_field_override entity with ID node.book.promote already exists. (core/lib/Drupal/Core/Entity/EntityStorageBase.php:399)

Proposed resolution

Figure out why this happens just for this entity and then maybe add a new destination and check that the entity doesn't already exist.

Remaining tasks

Write patch.

User interface changes

API changes

CommentFileSizeAuthor
#2 2405023-2.patch3.13 KBbenjy
#1 2405023-1.patch2.16 KBbenjy
#1 2405023-FAIL.patch836 bytesbenjy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

benjy’s picture

Status: Active » Needs review
FileSize
836 bytes
2.16 KB

Fail only patch attached. The problem is that $row->getDestinationProperty($this->getKey('id')) doesn't return the entity id for the base_field_override since the id is not in the incoming data but calculated from entity_type, bundle and field_name.

I've added a getEntityId() method to the Entity base class and then a base_field_override destination to override the new method.

benjy’s picture

FileSize
3.13 KB

Arh, missing the new file.

The last submitted patch, 1: 2405023-1.patch, failed testing.

The last submitted patch, 1: 2405023-FAIL.patch, failed testing.

ultimike’s picture

Benjy,

Do you think we need a comment in EntityBaseFieldOverride.php to explain that this class only exists for the test?

-mike

benjy’s picture

It isn't only for the test. This same error happens when you migrate to Drupal 8 and already have a content type in your Drupal 6 site that exists in D8. For example, page and article.

ultimike’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me (thanks for the hint).

-mike

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I'm not sure about this fix. Just using what is on the site that's being migrated to could be problematic. I think we need to report this to the user and ask them what to do... but this is a tricky issue.

benjy’s picture

+++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
@@ -106,7 +106,7 @@ public function fields(MigrationInterface $migration = NULL) {
+    $entity_id = $old_destination_id_values ? reset($old_destination_id_values) : $this->getEntityId($row);
     if (!empty($entity_id) && ($entity = $this->storage->load($entity_id))) {
       $this->updateEntity($entity, $row);
     }

But now it has a valid entity id it tries to update what's on the site?

chx’s picture

> Just using what is on the site that's being migrated to could be problematic.

So, we are not using that? It is loading and updating the entity if it exists. We have --independently of this issue-- discussed adding a flag called delete_existing which would delete the entity if it exists. Would you like the patch better if that flag got added first?

benjy’s picture

Status: Needs work » Reviewed & tested by the community

Just using what is on the site that's being migrated to could be problematic. I think we need to report this to the user and ask them what to do... but this is a tricky issue.

This destination attempts to load the entity from D8 first and then update appropriately otherwise create a new one if it didn't exist. This is inline with the other destinations currently in core.

Note: We will have a "delete_existing" feature coming soon that allows the user to choose whether they want the destination to try update first or always starts a fresh.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Migrate is not subject to beta evaluation. Committed fcb679d and pushed to 8.0.x. Thanks!

  • alexpott committed fcb679d on 8.0.x
    Issue #2405023 by benjy: Cannot create base_field_override entity, ID...

Status: Fixed » Closed (fixed)

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

sivarooban’s picture

how to apply this patch