Don't remove the buttons or moderation state info from an entity edit form - just enusre everything is disabled.

CommentFileSizeAuthor
#9 content_lock-3026024-9.patch542 bytesilianoz
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

rp7 created an issue. See original summary.

wim leers’s picture

Title: Moderation state can still be changed on locked entities » [regression] Moderation state can still be changed on locked entities
Related issues: +#2901090: Disable content moderation buttons

I think this is a regression, because AFAICT #2901090: Disable content moderation buttons also fixed this about 1.5 year ago. Probably Content Moderation's implementation in core changed in the mean time.

Ideally, we'd add an explicit functional test for this to prevent this from regressing again.

smustgrave’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

Tested on the latest 8.x-2.x

And I'm actually not seeing the moderation state on the locked node.

smustgrave’s picture

Title: [regression] Moderation state can still be changed on locked entities » Moderation state missing on locked entities
Status: Postponed (maintainer needs more info) » Needs review

I still can't replicate the original issue but not sure hiding the moderation state is correct either.

With this MR the moderation state is present but still correctly disabled.

smustgrave’s picture

rebased

alexpott’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Let's get some test coverage here so we can be sure this works on both Drupal 9 (which we still test on) and Drupal 10. If it only works on Drupal 10 it might be time to cut a new major.

smustgrave’s picture

Made the recommendation in slack but maybe we do a final release for 8.x-2.x and start a 3.0.x branch. And then we can drop D9 and merge in the change for D11 ticket.

Then can add test coverage for 3.0.x

ilianoz’s picture

StatusFileSize
new542 bytes
nnevill’s picture

Patch works for me (version 3.0.0-alpha4).
Thanks!

rob230’s picture

Got the same problem (of missing moderation state). The MR (or patch #9) fixes it. The content moderation controls are disabled if another user has locked the content, so I'm not sure why they were removed before.

alexpott’s picture

I've created an MR based on #9 - going to add test coverage.

alexpott’s picture

Category: Bug report » Task
Issue tags: +Needs issue summary update

This issue appears to be about two things. The issue summary is a bug report that @smustgrave cannot reproduce. The rest of the issue is a discussion about whether the moderation buttons should appear on not. Note that the module is doing

        // Do not allow deletion, publishing, or unpublishing if locked.
        foreach (['delete', 'publish', 'unpublish'] as $key) {
          if (isset($form['actions'][$key])) {
            unset($form['actions'][$key]);
          }
        }

just above this code. I think we should widen the scope to include discussion of all the buttons like this. And how #disabled on the tope level of a form works and if different browsers have different interpretations of this.

alexpott’s picture

So I think the problem here and why the unset is happening is because of code in FormBuilder

      // Make child elements inherit their parent's #disabled and #allow_focus
      // values unless they specify their own.
      foreach (['#disabled', '#allow_focus'] as $property) {
        if (isset($element[$property]) && !isset($element[$key][$property])) {
          $element[$key][$property] = $element[$property];
        }
      }

I think we need an after build to come it and ensure everything is truly disabled or otherwise this is fragile and probably we we were removing the elements.

alexpott changed the visibility of the branch 3026024-regression-moderation-state to hidden.

alexpott’s picture

Status: Needs work » Reviewed & tested by the community
alexpott’s picture

Issue summary: View changes
Issue tags: -Needs tests, -Needs issue summary update

  • alexpott committed 7270c996 on 3.x
    task: #3026024 Moderation state missing on locked entities
    
    By: alexpott...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

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.

alexpott’s picture

Version: 8.x-2.x-dev » 3.x-dev

This is only fixed on 3.x - won;t fix on 2.x because once 3.0.0 we're going to unsupport 2.x

Status: Fixed » Closed (fixed)

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