Fatal error in trackOnEntityUpdate logic -- No "original" property

Created on 7 July 2020, over 4 years ago
Updated 30 April 2024, 8 months ago

Hey there, encountering an issue with entity usage. Here are the two fatal errors we experience:

The two errors encountered were:

Call to a member function getRevisionId() on null
Call to undefined method
(I did not save the undefined method error output, so just capturing what I can recall here incase someone else reproduces it).

The issue as I am experiencing it is with a node that is revisionable, but does not have revisioning turned on. The original node is created programmatically in a behat step, and then we edit it via standard in browser behat testing steps. On save, we were getting both of the errors.

Adding the following sanity checks worked for me:

First, add an early exit if there is no original property.

// Exit immediately if no original. Somehow got to entity update unexpectedly.
    if (!isset($entity->original)) {
      return;
    }

...and second, just sanity check both objects have the required methods. RevisionableInterface should require it, but... I'm not experiencing that.

foreach ($fields as $field_name) {
      if (($source_entity instanceof RevisionableInterface) &&
        method_exists($source_entity, 'getRevisionId') &&
        method_exists($source_entity->original, 'getRevisionId') &&
        $source_entity->getRevisionId() != $source_entity->original->getRevisionId() &&
...
๐Ÿ› Bug report
Status

Active

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States jnicola

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.

Production build 0.71.5 2024