As we have sometimes the issue that a user goes home and the content is then locked the idea came up, that on log out all locks are removed.
It makes sense as then the user can't edit anything anymore so the lock can be removed.

On log out it just needs to make sure its the last session of the user, as the user can have multiple sessions it can happen that

Comments

kfritsche created an issue. See original summary.

kfritsche’s picture

Status: Active » Needs review
StatusFileSize
new1.79 KB

Here a first patch for this issue.

It does a workaround for detecting how many sessions are open for a single user. I created a issue for Drupal to see if maybe this problem can be solved there (#2937742: Add countSession for a user in SessionManager).

Otherwise this should do the trick.

Status: Needs review » Needs work

The last submitted patch, 2: content_lock-2937733-1.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

kfritsche’s picture

Assigned: kfritsche » Unassigned
Status: Needs work » Needs review
StatusFileSize
new11.61 KB
new12.43 KB

Moved the code from content_lock to content_lock_timeout where it makes more sense.

Also it doesn't break tests there, BUT I created tests for content_lock_timeout. Including old functions there.

On the way needed to fix some stuff, so the patch got quite big. Hope it would be okay to have this all in one issue.

Status: Needs review » Needs work

The last submitted patch, 4: content_lock-2937733-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

kfritsche’s picture

StatusFileSize
new7.12 KB
new12.83 KB

Disabled content_lock_timeout for normal tests, as with new logic these are failing. As there are now specific tests for content_lock_timeout this is not a problem.

Also fixing some coding standard issues.

kfritsche’s picture

Status: Needs work » Needs review
kfritsche’s picture

StatusFileSize
new2.79 KB
new13.01 KB

And some more coding standard issues.

hchonov’s picture

  1. +++ b/modules/content_lock_timeout/content_lock_timeout.module
    @@ -69,7 +70,7 @@ function content_lock_timeout_entity_prepare_form(EntityInterface $entity, $oper
    -      && is_object($lock = $lock_service->fetchLock($entity->id(), $entity->getEntityTypeId()))
    +      && is_object($lock = $lock_service->fetchLock($entity->id(), $entity->getEntityTypeId(), $operation, $entity->getEntityTypeId()))
    

    Well it looks like we had this error for some time now :).

    The second parameter of \Drupal\content_lock\ContentLock\ContentLock::fetchLock() is $langcode :).

  2. +++ b/modules/content_lock_timeout/content_lock_timeout.module
    @@ -98,3 +99,37 @@ function content_lock_timeout_entity_prepare_form(EntityInterface $entity, $oper
    +  // Otherwise its not sure if sessions table has correct data. As it would be
    +  // a common practice to extend the Class, instanceof is not used here!
    

    I would not say that it "would be a common practice" but just mention that it is possible.

kfritsche’s picture

StatusFileSize
new1.42 KB
new13 KB

Both comments fixed

hchonov’s picture

Status: Needs review » Reviewed & tested by the community

It looks good to me. Thank you.

chr.fritsch’s picture

Status: Reviewed & tested by the community » Fixed

Looks pretty solid to me. Thank you

Status: Fixed » Closed (fixed)

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