_scheduler_content_moderation_integration_states_values should leverage content_moderation.state_transition_validation

Created on 22 September 2023, over 1 year ago

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

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mglaman
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    21 pass, 8 fail
  • @mglaman opened merge request.
  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    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.

  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    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

Production build 0.71.5 2024