Skip to content

Commit

Permalink
VACMS-15559 Remove conflation of new revision and new node.
Browse files Browse the repository at this point in the history
  • Loading branch information
swirtSJW committed Jan 31, 2024
1 parent ca43a74 commit 5009f9a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/content/script-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,18 @@ function save_node_revision(NodeInterface $node, $message = '', $new = TRUE): in
$node->setNewRevision($new);
$node->setSyncing(TRUE);
$node->setValidationRequired(FALSE);
$node->enforceIsNew(FALSE);
// New revisions deserve special treatment.
if ($new) {
$node->enforceIsNew(TRUE);
$node->setChangedTime(time());
$node->setRevisionCreationTime(time());
$uid = CMS_MIGRATOR_ID;
}
else {
$node->enforceIsNew(FALSE);
$uid = $node->getRevisionUserId();
// Append new log message to previous log message.
$prefix = !empty($message) ? $node->getRevisionLogMessage() . ' - ' : '';
$message = $prefix . $message;
}
$node->setRevisionUserId($uid);
$revision_time = $node->getRevisionCreationTime();
Expand All @@ -227,9 +229,7 @@ function save_node_revision(NodeInterface $node, $message = '', $new = TRUE): in
// the value is not different from the original value.
$revision_time++;
$node->setRevisionCreationTime($revision_time);
// Append new log message to previous log message.
$prefix = !empty($message) ? $node->getRevisionLogMessage() . ' - ' : '';
$node->setRevisionLogMessage($prefix . $message);
$node->setRevisionLogMessage($message);
$node->set('moderation_state', $moderation_state);

return $node->save();
Expand Down

0 comments on commit 5009f9a

Please sign in to comment.