Problem/Motivation
Trying to migrate some node revisions using the drupal migration system (Drupal 8.8), I am getting the following error:
Call to a member function getTranslation() on null in Drupal\Core\Entity\ContentEntityBase->hasTranslationChanges
It seems that it cannot get the original entity and call the function getTranslation() on it. So, possibly, a check for the existence of the original entity, could avoid this error, although the root of the problem may be that an original entity should always exist and it should never be null (then there might be a problem with the migrated content).
Steps to reproduce
Migrating an updated entity that exists in the destination:
- Generate a node complete migration for 2 node types from a Drupal 7 source database.
- Run initial node complete migrations from Drupal 7 source database.
- Create a new revision on node type #1 in the Drupal 7 source database.
- Create a new revision on node type #2 in the destination database with the same revision id as used in the Drupal 7 source database (simulating auto-incrementing sequences from the same state).
- Run node complete migration for node type #1 from Drupal 7 source database.
Migrating a new entity that exists in the destination:
- Generate a node complete migration for 2 node types from a Drupal 7 source database.
- Run initial node complete migrations from Drupal 7 source database.
- Create a new node of node type #1 in the Drupal 7 source database.
- Create a new revision on node type #2 in the destination database with the same revision id as used in the Drupal 7 source database (simulating auto-incrementing sequences from the same state).
- Run node complete migration for node type #1 from Drupal 7 source database.
Proposed resolution
1. Check whether the entity loaded by revision id found in the destination database has the same destination entity id.
2. If not, if the destination entity id exists in the destination database, create a new revision.
3. If the destination entity id does not exist in the destination database, ensure that a new entity is created with a new revision.
4. Throw a migrate exception when a translation is not found, but expected.
Remaining tasks
The current patch ignores the fatal error, but results in a caught error being thrown for some content but not all content being migrated.
- Figure out if the merge request approach works.
- Write kernel tests based on steps to reproduce.
User interface changes
No
API changes
TBD
Data model changes
No
Release notes snippet