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
- Enable the Workflows module
- Add Basic Page as applying to the 'Editorial' workflow
- Create and move a basic page through the workflow to published, then set to draft
- Finally, edit the non-default revision (draft) basic page again and set it to ready for review
- 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.