Problem/Motivation
* Have a (non-revisionable, e.g. user) entity and a field_paragraph
* Solve a problem where you need to act depending on the paragraph change (so need the original paragraph) *and* the host entity ID.
Expected:
* In hook_user_insert, developer can access $user->original->field_paragraph *or* $user->field_paragraph->original to get the original paragraph
Experienced:
* Nope
Note that acting in hook_paragraph_insert is not a workaround as $user->id() is not determined here.
OTOH, in hook_user_insert, the paragraph is already saved and $paragraph->original had been deleted by EntityStorageBase::doPostSave.
I worked around this by some userland caching of the original paragraph, but this is plain insane and a real kitten massacre.
Proposed resolution
I see 2 viable approaches:
a) Enrich $entity->original:
* 1) In presave, when $entity->original is set, care that all entityreference fields get a clone of its referenced entity.
b) Make $paragraph->original endure:
* 1) (By deferring the unset()) Somehow prevent or undo deleting $paragraph->original after paragraph save. Then delete it after last host entity is saved.
Remaining tasks
User interface changes
API changes
Data model changes