diff -u b/core/lib/Drupal/Core/Entity/Form/RevisionableContentEntityForm.php b/core/lib/Drupal/Core/Entity/Form/RevisionableContentEntityForm.php --- b/core/lib/Drupal/Core/Entity/Form/RevisionableContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/Form/RevisionableContentEntityForm.php @@ -17,7 +17,7 @@ /** * The entity being used by this form. * - * @var \Drupal\Core\Entity\ContentEntityInterface + * @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\Core\Entity\RevisionLogInterface */ protected $entity; @@ -170,18 +170,19 @@ * next step. */ public function submitForm(array &$form, FormStateInterface $form_state) { - // Build the node object from the submitted values. + // Build the entity object from the submitted values. parent::submitForm($form, $form_state); - $node = $this->entity; + $entity = $this->entity; // Save as a new revision if requested to do so. - if (!$form_state->isValueEmpty('revision') && $form_state->getValue('revision') != FALSE) { - $node->setNewRevision(); + if (!$form_state->isValueEmpty('revision')) { + $entity->setNewRevision(); // If a new revision is created, save the current user as revision author. - $node->setRevisionUserId(\Drupal::currentUser()->id()); + $entity->setRevisionUserId(\Drupal::currentUser()->id()); + $entity->setRevisionCreationTime(REQUEST_TIME); } else { - $node->setNewRevision(FALSE); + $entity->setNewRevision(FALSE); } } @@ -189,10 +190,6 @@ * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { - // Save as a new revision if requested to do so. - if (!$form_state->isValueEmpty('revision')) { - $this->entity->setNewRevision(); - } $insert = $this->entity->isNew(); $this->entity->save(); diff -u b/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php --- b/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -135,9 +135,6 @@ // one. $record->revision_log = $this->original->getRevisionLogMessage(); } - else { - $this->setRevisionCreationTime(REQUEST_TIME); - } } /** reverted: --- b/core/modules/node/src/Entity/Node.php +++ a/core/modules/node/src/Entity/Node.php @@ -123,9 +123,6 @@ // entry with an empty one. $record->revision_log = $this->original->revision_log->value; } - else { - $record->revision_timestamp = REQUEST_TIME; - } } /** diff -u b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php --- b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php @@ -3,6 +3,8 @@ namespace Drupal\entity_test\Entity; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\RevisionLogEntityTrait; +use Drupal\Core\Entity\RevisionLogInterface; use Drupal\Core\Field\BaseFieldDefinition; /** @@ -45,7 +47,9 @@ * } * ) */ -class EntityTestRev extends EntityTest { +class EntityTestRev extends EntityTest implements RevisionLogInterface { + + use RevisionLogEntityTrait; /** * {@inheritdoc} @@ -53,6 +57,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields = parent::baseFieldDefinitions($entity_type); + $fields += static::revisionLogBaseFieldDefinitions($entity_type); + $fields['name']->setRevisionable(TRUE); $fields['user_id']->setRevisionable(TRUE);