PHP error when stored entity is not found

Created on 6 August 2020, over 4 years ago
Updated 7 March 2023, almost 2 years ago

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

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇺🇸United States benjifisher Boston area

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India kapil17

    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.

  • 🇺🇸United States benjifisher Boston area

    @kapil17:

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

Production build 0.71.5 2024