- Issue created by @tedbow
Discovered in π Page revisions are missing information about author Active
The problem is in \Drupal\experience_builder\Controller\ApiAutoSaveController::post()
$use_existing_revision_id = AutoSaveManager::contentEntityIsConsideredNew($entity);
if ($entity instanceof EntityPublishedInterface) {
$entity->setPublished();
}
// If the entity is new, the autosaved data is considered to be part
// of the first revision. Therefore, do not create a new revision
// for new entities.
if ($use_existing_revision_id) {
$entity->setNewRevision(FALSE);
}
else {
// Reset the revision ID.
$entity->setNewRevision();
$revision_id_key = $entity_definition->getKey('revision');
\assert(\is_string($revision_id_key));
$entity->set($revision_id_key, NULL);
}
there are 2 problems with this
$use_existing_revision_id = AutoSaveManager::contentEntityIsConsideredNew($entity);
Because contentEntityIsConsideredNew()
determines this by the title it will never return true unless the title was unchanged from when it was started. I believe intention here is that if the first time an entity is created in XB there should only be 1 revision after the first publish.
So to fix that think we would want
$use_existing_revision_id = AutoSaveManager::contentEntityIsConsideredNew($originalEntity);
We already have $originalEntity
at this point
$use_existing_revision_id = TRUE
does not actually result in a new revision not being created.
Debugging I can see that even though $entity->setNewRevision(FALSE);
is called when publishing a page a new revision is always created.
This is somewhat related to π Page revisions are missing information about author Active because this means the old revision will always be made by anonymous user.
$use_existing_revision_id = AutoSaveManager::contentEntityIsConsideredNew($originalEntity);
so that this doesn't only return true when the title has remained unchanged before publishing the first time$entity->setNewRevision(FALSE);
still results in a new revision when publishingThere should be only 1 revision, by the publishing user, when a XB page is published
Active
0.0
Auto-save