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

CommentFileSizeAuthor
#2 3163662-2.patch777 bytesbenjifisher

Comments

benjifisher created an issue. See original summary.

benjifisher’s picture

Assigned: benjifisher » Unassigned
StatusFileSize
new777 bytes

Here is a patch that seems to work in my case.

benjifisher’s picture

Status: Active » Needs review
greggmarshall’s picture

Status: Needs review » Reviewed & tested by the community

We ran into the same error message inside Taxonomy Manager when editing a taxonomy term and this patch resolved it.

Thanks @benjifisher.

joseph.olstad’s picture

just hit this, please commit the fix!

benjifisher’s picture

@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.

joseph.olstad’s picture

Unfortunately 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.

jmlavarenne’s picture

I also faced the same issue, exact same message error, and cannot provide steps to reproduce. The patch solved it for me. Thanks!

kapil17’s picture

faced the same issue while using entity clone module. Steps to reproduce :

  • Once entity clone is configured, clone any entity
  • Edit that cloned entity, Go to menu link option
  • Add the cloned entity in any nested menu item.
  • Hit save and you will face the same error.

verified and tested the above patch it is working fine.

benjifisher’s picture

Issue summary: View changes

@kapil17:

Thanks for the steps to reproduce. I am updating the issue summary to refer to your comment.