Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294221

ContentEntityBase::getLoadedRevisionId() returns NULL in some circumstances

$
0
0

Problem/Motivation

Not sure if this is something particular to my installation, but after upgrading core from 8.6.13 to 8.7.0-beta1, a node save operation started throwing warnings of type:

Trying to get property 'value' of non-object

at

\Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator::getOriginalOrInitialState()

/var/www/html/docroot/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php line 160

Stepping there with the debugger shows that when the error is thrown, $original_entity is empty, and that is because $entity->getLoadedRevisionId() some lines above also returns NULL.

See below the full trace, in case it helps.

Proposed resolution

Not sure why in the \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator::isFirstTimeModeration() some lines below, the $original_entity is retrieved differently. It seems like using the same approach in the ::getOriginalOrInitialState() method is enough to solve the issue. I ignore however if this is just a band-aid to hide the issue or it could be a legitimate fix.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 294221

Trending Articles