Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | 2405023-2.patch | 3.13 KB | benjy |
#1 | 2405023-1.patch | 2.16 KB | benjy |
#1 | 2405023-FAIL.patch | 836 bytes | benjy |
Comments
Comment #1
benjy CreditAttribution: benjy commentedFail 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.
Comment #2
benjy CreditAttribution: benjy commentedArh, missing the new file.
Comment #5
ultimikeBenjy,
Do you think we need a comment in EntityBaseFieldOverride.php to explain that this class only exists for the test?
-mike
Comment #6
benjy CreditAttribution: benjy commentedIt 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.
Comment #7
ultimikeLooks good to me (thanks for the hint).
-mike
Comment #8
alexpottI'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.
Comment #9
benjy CreditAttribution: benjy commentedBut now it has a valid entity id it tries to update what's on the site?
Comment #10
chx CreditAttribution: chx commented> 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?Comment #11
benjy CreditAttribution: benjy commentedThis 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.
Comment #12
alexpottMigrate is not subject to beta evaluation. Committed fcb679d and pushed to 8.0.x. Thanks!
Comment #15
sivarooban CreditAttribution: sivarooban commentedhow to apply this patch