Problem/Motivation
When editing a custom entity, I get the following PHP error when trying to save:
Error: Call to a member function hasTranslation() on boolean in Drupal\conflict\Entity\ContentEntityConflictHandler->entityFormEntityBuilder() (line 220 of /var/www/docroot/modules/contrib/conflict/src/Entity/ContentEntityConflictHandler.php)
Steps to reproduce
See Comment #9.
Original report:
I am not really sure. Sorry, there is a lot of custom code in my current project, and some of it is questionable. Maybe the entity was created from a custom form that did not extend whatever base class the Conflict module assumes, so the Conflict module's methods were not invoked when the entity was initially created. That is just a guess.
Proposed resolution
Check $entity_original and exit early if it is empty.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3163662-2.patch | 777 bytes | benjifisher |
Comments
Comment #2
benjifisherHere is a patch that seems to work in my case.
Comment #3
benjifisherComment #4
greggmarshallWe ran into the same error message inside Taxonomy Manager when editing a taxonomy term and this patch resolved it.
Thanks @benjifisher.
Comment #5
joseph.olstadjust hit this, please commit the fix!
Comment #6
benjifisher@greggmarshall, @joseph.olstad:
It will help the module maintainers if one of you could update the issue summary with reliable steps to reproduce the error.
Comment #7
joseph.olstadUnfortunately I don't have the steps to reproduce, this patch is harmless though.
It could be due to some orphaned records in our system from resetting table counters and deleting entities perhaps missed some conflicts carried over during our migrations/upgrades.
Either way, a conflict should not be compared against an empty entity_original.
This is a 3 line patch about as simple as they come.
Comment #8
jmlavarenne commentedI also faced the same issue, exact same message error, and cannot provide steps to reproduce. The patch solved it for me. Thanks!
Comment #9
kapil17 commentedfaced the same issue while using entity clone module. Steps to reproduce :
verified and tested the above patch it is working fine.
Comment #10
benjifisher@kapil17:
Thanks for the steps to reproduce. I am updating the issue summary to refer to your comment.