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

Hook presave does not set original correctly when editing non-default revision entities

$
0
0

Problem/Motivation

\Drupal\Core\Entity\EntityStorageBase::doPreSave does not reload the 'original' node into $entity->original when workflows are enabled for the bundle and the entity being updated is not the 'Default Revision'.

Steps to reproduce

  1. Enable the Workflows module
  2. Add Basic Page as applying to the 'Editorial' workflow
  3. Create and move a basic page through the workflow to published, then set to draft
  4. Finally, edit the non-default revision (draft) basic page again and set it to ready for review
  5. In a presave hook, $entity->original will be set to the published revision instead of the draft revision.

Proposed resolution

\Drupal\Core\Entity\EntityStorageBase::doPreSave uses \Drupal\Core\Entity\EntityStorageBase::loadUnchanged instead of loading by the node's revision ID when the entity is not the default revision.

Workaround

Load the 'original' yourself in hook presave via the entity's revision ID.


Viewing all articles
Browse latest Browse all 296327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>