Problem/Motivation

This is the same problem that affects host entities as described in core bug #2977362: Revision user incorrectly appears as anonymous user when node author is canceled, but for referenced entities.

When the user account of the owner of an entity is cancelled, and the option is chosen to reassign the ownership of the entity to the anonymous user, the following error can be thrown:

Drupal\Core\Entity\EntityStorageException: An existing default revision of the 'paragraph' entity type can not be changed to a non-default revision. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). Drupal\Core\Entity\EntityStorageBase->save() (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 370)
Drupal\Core\Entity\EntityBase->save() (Line: 310)
Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem->preSave() (Line: 233)
Drupal\Core\Field\FieldItemList->delegateMethod() (Line: 191)
Drupal\Core\Field\FieldItemList->preSave() (Line: 954)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod() (Line: 904)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook() (Line: 530)
Drupal\Core\Entity\EntityStorageBase->doPreSave() (Line: 760)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave() (Line: 484)
Drupal\Core\Entity\EntityStorageBase->save() (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 370)
Drupal\Core\Entity\EntityBase->save() (Line: 99)
_node_mass_update_helper() (Line: 146)
_node_mass_update_batch_process() (Line: 298)

This can happen if there are unpublished forward revisions present, e.g. by using content moderation.

In the core issue this has been solved by setting the syncing flag, which preserves forward revisions. It looks like propagating the flag to the referenced entity prevents the exception from being thrown.

Steps to reproduce

Proposed resolution

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pfrenssen created an issue. See original summary.

pfrenssen’s picture

Status: Active » Postponed

I did some very limited testing, but it looks like propagating the syncing state from the host entity to the referenced entity is enough to prevent the exception from being thrown.

In any case this is postponed until #2977362: Revision user incorrectly appears as anonymous user when node author is canceled is in.

pfrenssen’s picture