function Node::preSaveRevision

Same name and namespace in other branches
  1. 9 core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::preSaveRevision()
  2. 8.9.x core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::preSaveRevision()
  3. 10 core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::preSaveRevision()

Overrides ContentEntityBase::preSaveRevision

File

core/modules/node/src/Entity/Node.php, line 137

Class

Node
Defines the node entity class.

Namespace

Drupal\node\Entity

Code

public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
  parent::preSaveRevision($storage, $record);
  if (!$this->isNewRevision() && $this->getOriginal() && (!isset($record->revision_log) || $record->revision_log === '')) {
    // If we are updating an existing node without adding a new revision, we
    // need to make sure $entity->revision_log is reset whenever it is empty.
    // Therefore, this code allows us to avoid clobbering an existing log
    // entry with an empty one.
    $record->revision_log = $this->getOriginal()->revision_log->value;
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.