Problem/Motivation

This module hardcodes logic for allowed transitions:

  $user = \Drupal::currentUser();
  $user_transitions = array_filter($type_plugin->getTransitions(), function (Transition $transition) use ($workflow, $user) {
    return $user->hasPermission('use ' . $workflow->id() . ' transition ' . $transition->id());
  });

It should invoke \Drupal\content_moderation\StateTransitionValidationInterface::getValidTransitions

We've made it so that administer * permissions allow using transitions. But this module has its logic hardcoded.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs work

I believe this uncovered bugs in the tests.

  public function testValidPublishStateToUnPublishStateTransition() {
    $node = Node::create([
      'type' => 'example',
      'title' => 'Test title',
      'moderation_state' => 'draft',
      'unpublish_on' => strtotime('+3 days'),
      'publish_on' => strtotime('+2 days'),
      'unpublish_state' => 'archived',
      'publish_state' => 'published',
    ]);

    $violations = $node->validate();
    $this->assertCount(0, $violations, 'Both transitions should pass validation');
  }

This is failing. But draft -> archive was never a valid transition. From draft only create_new_draft and publish are valid.

EDIT: Ah but the possible valid ones need to be considered if it's schedule to be unpublished after being published...

jonathan1055’s picture

Version: 2.0.0-beta1 » 3.0.x-dev

Thanks for this, @mglaman.
Moving to the 3.x branch as it would have to be done there first. Open a new MR, as we can use MR48 if it gets back-ported to 2.x

smustgrave made their first commit to this issue’s fork.

  • smustgrave committed 99cc10d7 on 3.0.x authored by mglaman
    Issue #3389201: _scheduler_content_moderation_integration_states_values...
smustgrave’s picture

Status: Needs work » Fixed

Got this working!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.