diff --git a/core/modules/content_moderation/src/Form/RevisionRevertForm.php b/core/modules/content_moderation/src/Form/RevisionRevertForm.php index d27dcf3..612799a 100644 --- a/core/modules/content_moderation/src/Form/RevisionRevertForm.php +++ b/core/modules/content_moderation/src/Form/RevisionRevertForm.php @@ -78,8 +78,13 @@ public function buildForm(array $form, FormStateInterface $form_state, $node_rev $current_state = $this->revision->moderation_state->value; $workflow = $this->moderationInformation->getWorkflowForEntity($this->revision); + // Valid transitions are determined not from the this revision, but + // rather, from the default state of a new revision. If a user has no + // permissions for any of these transitions, the form is hidden. + $new_entity = $this->revision->createDuplicate(); + /** @var \Drupal\workflows\Transition[] $transitions */ - $transitions = $this->validation->getValidTransitions($this->revision, $this->currentUser()); + $transitions = $this->validation->getValidTransitions($new_entity, $this->currentUser()); $target_states = []; @@ -89,11 +94,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $node_rev if (!count($target_states)) { // Set to the initial state for this workflow since the user has no - // access to transitions from this state. A fake 'new' entity is used - // since the intent here is to get the default state, not the initial - // state of a published revision. - // @todo This seems messy. - $new_entity = $this->revision->createDuplicate(); + // access to transitions from this state. $form['new_state'] = [ '#type' => 'value', '#value' => $workflow->getTypePlugin()->getInitialState($new_entity)->id(),