Overrides \Drupal\Core\Entity\DatabaseStorageController::preSaveRevision().
Overrides DatabaseStorageController::preSaveRevision
protected function preSaveRevision(\stdClass $record, EntityInterface $entity) {
if ($entity
->isNewRevision()) {
// When inserting either a new custom block or a new custom_block
// revision, $entity->log must be set because {block_custom_revision}.log
// is a text column and therefore cannot have a default value. However,
// it might not be set at this point (for example, if the user submitting
// the form does not have permission to create revisions), so we ensure
// that it is at least an empty string in that case.
// @todo: Make the {block_custom_revision}.log column nullable so that we
// can remove this check.
if (!isset($record->log)) {
$record->log = '';
}
}
elseif (isset($entity->original) && (!isset($record->log) || $record->log === '')) {
// If we are updating an existing custom_block without adding a new
// revision, we need to make sure $entity->log is reset whenever it is
// empty. Therefore, this code allows us to avoid clobbering an existing
// log entry with an empty one.
$record->log = $entity->original->log->value;
}
}