Problem/Motivation
New revisions that follow a previous unpublished default revision are always made the new default revision regardless of any workflow settings to the contrary. This is in contrast to the behavior experienced for revisions following a published default revision.
As a result, "forward drafts" can not be "set as current revision" prior to a state change (to a state that makes it "Published" for example). This behavior is possible when "forward drafts" are created while the current default revision is published.
I believe that this can be traced back to an issue before the workbench_moderation
module was copied to core (Latest revision should become default revision when entity has never been published). It appears that the original intent was to make each new revision of an entity that was not yet published the new default revision as it is created.
This is supported in the issue description:
Given I create a moderatable entity in a non-published state (e.g., draft)
And I transition the entity to another non-published state (e.g., review)
Then the latest revision should become the default revision
However, if an entity has been previously published, and then unpublished, it doesn't seem to make sense to continue to make each subsequent revision the default revision any longer.
Steps to reproduce
- Create a revisionable entity with the default workflow assigned.
- Create a new revision with a moderation state that is "published."
- Create a new revision with a moderation state that is "unpublished."
- Create a new revision with a moderation state that does not have the "Default Revision" checkbox checked.
- Observe that the new revision is the default revision.
Proposed resolution
Adjust the technique used to determine if an entity revision should be set to "default revision".
See Drupal\content_moderation\EntityOperations::entityPresave()