Get node lock message "The content has either been modified by another user..." when editing a node published by scheduled_transitions with "recreate pending revision" enabled
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3210877. -->
Reported by: [sonnykt](https://www.drupal.org/user/884326)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>After a node is published by scheduled_transition with the option "Recreate pending revision" enabled, I am no longer able to edit that node because of the error message "<code>The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.</code>".</p>
<!--break--><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>* Create a draft revision (A) of a node. This revision is the latest revision.<br>
* Schedule to publish that revision A: select the revision ID from Scheduled Transitions dialogue, not the "Latest revision" option (with "Automatically determines the latest revision at time of transition"), tick the checkbox "Recreate pending revision"<br>
* Create another draft revision B<br>
* Run cron to trigger scheduled transitions.</p>
<h4 id="summary-steps-reproduce">Expected results</h4>
<p>* The node is published with content from revision A.<br>
* The latest revision is not published and has content from revision B.<br>
* The node can be edited and saved without any error.</p>
<h4 id="summary-steps-reproduce">Actual results</h4>
<p>* The node is published with content from revision A.<br>
* The latest revision is not published and has content from revision B.<br>
* The node cannot be saved because of the error message "<code>The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.</code>".</p>
<p>This issue occurs on both version 8.x-1.1 and 2.0.0.</p>
<h4 id="summary-steps-reproduce">Debugging</h4>
<p>Looking at the <code>node_field_revision</code> table:<br>
<img src="https://www.drupal.org/files/issues/2021-04-27/Screen%20Shot%202021-04-27%20at%204.21.12%20pm.png" alt="screenshot"><br>
* The revision A to be scheduled for publishing is vid #52153.<br>
* The revision B is vid #52154<br>
* Scheduled Transition copies #52153 to #52155 and publishes it (expected).<br>
* Scheduled Transition copies #52154 to #52156 as the latest revision and set it as draft (expected).<br>
* However, the latest revision #52156 has the same <code>changed</code> timestamp (1619503497) with #52154, whereas the current revision #52155 has a newer <code>changed</code> timestamp (1619503557).<br>
* The latest revision has an older timestamp than the current revision, hence it triggers the <code>EntityChanged</code> constraint upon node edit form submission.</p>
issue