plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
243 stars 186 forks source link

Traceback when cutting / deleting content with lock created by current user #3846

Closed laulaz closed 10 months ago

laulaz commented 11 months ago

BUG

What I did:

  1. Edit a content and leave the page (without saving / cancelling edition)
  2. Try to delete the object (Actions > Delete)

What I expect to happen:

I should be able to delete the object.

What actually happened:

The object is locked (which is normal), but I don't have any warning since it is locked by me (and not by another user). I should be able to delete the object, even if it is locked for other users. But it fails.

Some work has been done since https://github.com/plone/Products.CMFPlone/issues/1876 in plone.app.content, but it is not handling use cases where the lock is created by the current user. The only place where you can get any information about this lock is through the folder_contents cut / delete actions (ex: in https://github.com/plone/plone.app.content/pull/70), even if the user has maybe no clue of how to unlock the content (no button, no action --> he needs to edit it again) :

folder_contents

We should IMHO automatically unlock the object when the lock is created by the current user (for cutting / deleting).

The traceback the user gets when deleting is:

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 390, in publish_module
  Module ZPublisher.WSGIPublisher, line 285, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module z3c.form.form, line 233, in __call__
  Module z3c.form.form, line 228, in update
  Module plone.app.z3cform.csrf, line 21, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 301, in __call__
  Module z3c.form.button, line 159, in __call__
  Module plone.app.content.browser.actions, line 79, in handle_delete
  Module plone.dexterity.content, line 773, in manage_delObjects
  Module OFS.ObjectManager, line 550, in manage_delObjects
zExceptions.ResourceLockedError: Object "test" is locked.

What version of Plone/ Addons I am using:

Plone 6.0.6

Live demo:

https://github.com/plone/Products.CMFPlone/assets/1101273/e20675c7-9929-454e-9007-79fa6ac3997a

petschki commented 11 months ago

Yes, locking behavior bites us also every now and then. It's very subtle but in the toolbar you see the "lock" icon before the modification date which indicates that the object is locked. I thought it's colored differently in that case though. Additionally we could "disable" the action links when the object is locked.

laulaz commented 10 months ago

@petschki OK, now I see the lock icon 😄 ... but anyway, if the object is locked by you, you don't get any clear warning (but a traceback when cutting / deleting) nor any way to unlock the object. When you edit the content, the lock is "transparent" (you don't realize it was locked by you), I think it should be the same when you cut / delete the object.

laulaz commented 10 months ago

Disabling the action links when the object is locked would be another good option if and only if the user has a clear way to unlock the object (for now, he has to know that it is locked and that in that case he must edit -> cancel ... there is no "unclock" button for him).

davisagli commented 10 months ago

Fixed in https://github.com/plone/plone.app.content/pull/267