hook update no longer sees whether a new revision was saved

Created on 3 July 2019, over 5 years ago
Updated 21 January 2024, 10 months ago

#2544790: ContentEntityBase::setNewRevision(FALSE) is broken if ::setNewRevision(TRUE) was called previously β†’ added $this->newRevision = FALSE; to ContentEntityBase::postSave. Now, EntityStorageBase::doSave has

    $entity->postSave($this, $update);
    $this->invokeHook($update ? 'update' : 'insert', $entity);

meaning update hook implementations no longer see whether a new revision was saved or not. ContentEntityStorageBase::doPostSave always called $entity->setNewRevision(FALSE); but this call happened _after_ the parent::doPostSave($entity, $update); call which in turn calls the hooks as quoted above. Removing $this->newRevision = FALSE; seems like the easy solution but I do not know it well enough to be sure it's the right thing to do. I will submit a patch doing so then we will see.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 5 hours ago

Created by

πŸ‡¨πŸ‡¦Canada Charlie ChX Negyesi 🍁Canada

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.

  • πŸ‡¬πŸ‡·Greece pappis Greece

    I am trying to access route
    diff.revisions_diff: '/node/{node}/revisions/view/{left_revision}/{right_revision}/{filter}'
    from inside hook_node_update(NodeInterface $node)
    but i get
    TypeError: Argument 3 passed to Drupal\diff\Controller\PluginRevisionController::compareEntityRevisions() must implement interface Drupal\Core\Entity\ContentEntityInterface, null given

    probably because the new revision is not saved when the hook runs.

    Is it related to this issue and is there a workaround?

Production build 0.71.5 2024