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
CER module is installed and configured on a D8 site. While migrating a D6 nodes into the D8 site, the corresponding entity may not be available yet. CER seems to assume that the corresponding entity is available and breaks the migration with:
Argument 2 passed to [error]
Drupal\corresponding_reference\Entity\CorrespondingReference::synchronizeCorrespondingField()
must implement interface Drupal\Core\Entity\FieldableEntityInterface, null given, called in
/Users/erikstielstra/www/drupal8/docroot/modules/custom/corresponding_reference/src/Entity/CorrespondingReference.php
on line 249 and defined CorrespondingReference.php:302
Proposed resolution
A simple 'if' wrapper in code could be sufficient.
Comment | File | Size | Author |
---|---|---|---|
#2 | cer-breaks-migration-2861834-2.patch | 798 bytes | Sutharsan |
Comments
Comment #2
Sutharsan CreditAttribution: Sutharsan at LimoenGroen commentedThis change made the migration work.
Comment #3
maijs CreditAttribution: maijs at Wunder commentedThis error also occurs when a referenced entity (B) is deleted while an entity (A) which references the entity B is being edited and then saved. At that point the referenced entity is no longer available, and it causes TypeError to be thrown:
TypeError: Argument 2 passed to Drupal\cer\Entity\CorrespondingReference::synchronizeCorrespondingField() must implement interface Drupal\Core\Entity\FieldableEntityInterface, null given, called in /Users/xyz/Sites/xyz/web/modules/contrib/cer/src/Entity/CorrespondingReference.php on line 249 in Drupal\cer\Entity\CorrespondingReference->synchronizeCorrespondingField() (line 296 of modules/contrib/cer/src/Entity/CorrespondingReference.php).
The patch in #2 does fix the issue.
Comment #4
maijs CreditAttribution: maijs at Wunder commentedChanging the title as the issue is broader than initially thought.
Comment #5
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedThanks for finding this issue, and the simple solution posted! It looks good to me.
Comment #7
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedThanks for the patch! And also thanks for testing and confirming the larger issue maijs! Should be fixed in the dev version now, and rolled up to a new release version soon.