Skip to main content
added 13 characters in body
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

I am using D8 and creating revision for a node with the following code.

  $nid = "my_node_id";
  $node = \Drupal\node\Entity\Node::load($nid);
// Make this change a new revision
  $node->setNewRevision(TRUE);
  $node->revision_log = 'Created revision for node' . $nid;
  $node->setRevisionCreationTime(REQUEST_TIME);
  $node->setRevisionUserId($user_id);
  $node->save();

When I create a revision, it is set as the main revision, instead of one of the revisions. Is it taking the revision timestamp when creating, and pushing latest to the top? Is there a function that tells me I am using the latest revision?

I am creating revision for a node with the following code.

  $nid = "my_node_id";
  $node = \Drupal\node\Entity\Node::load($nid);
// Make this change a new revision
  $node->setNewRevision(TRUE);
  $node->revision_log = 'Created revision for node' . $nid;
  $node->setRevisionCreationTime(REQUEST_TIME);
  $node->setRevisionUserId($user_id);
  $node->save();

When I create a revision, it is set as the main revision, instead of one of the revisions. Is it taking the revision timestamp when creating, and pushing latest to the top? Is there a function that tells me I am using the latest revision?

I am using D8 and creating revision for a node with the following code.

  $nid = "my_node_id";
  $node = \Drupal\node\Entity\Node::load($nid);
// Make this change a new revision
  $node->setNewRevision(TRUE);
  $node->revision_log = 'Created revision for node' . $nid;
  $node->setRevisionCreationTime(REQUEST_TIME);
  $node->setRevisionUserId($user_id);
  $node->save();

When I create a revision, it is set as the main revision, instead of one of the revisions. Is it taking the revision timestamp when creating, and pushing latest to the top? Is there a function that tells me I am using the latest revision?

edited tags; edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
edited body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Loading
Source Link
KTM
  • 2.4k
  • 4
  • 47
  • 70
Loading