Problem/Motivation

It should be possible to lock only an entity translation instead of the whole entity in order to enable concurrent editing of different entity translations, which was just made possible by the conflict module.

Proposed resolution

To all methods consuming the entity ID provide the entity translation language as well and if configured so lock on entity translation level instead on entity level.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

hchonov created an issue. See original summary.

hchonov’s picture

Status: Active » Needs review
StatusFileSize
new23.9 KB

Status: Needs review » Needs work

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

kfritsche’s picture

Status: Needs work » Needs review
StatusFileSize
new26.03 KB
new3.25 KB

Translation lock should only be available if conflict module exists or similar functionality is implemented in core.

Till then only enable this option if conflict is enabled. Otherwise user will have conflicts again or thinks this resolution is already provided by this module.

Status: Needs review » Needs work

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

kfritsche’s picture

Status: Needs work » Needs review
StatusFileSize
new27.72 KB
new1.28 KB

This should fix the current tests.

New tests would be nice, but not sure if I get to it soon :/

Status: Needs review » Needs work

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

kfritsche’s picture

Status: Needs work » Needs review
StatusFileSize
new3.41 KB
new27.59 KB

Fixing test and doing some coding standards love.

hchonov’s picture

Translation lock should only be available if conflict module exists or similar functionality is implemented in core.

Till then only enable this option if conflict is enabled. Otherwise user will have conflicts again or thinks this resolution is already provided by this module.

This totally makes sense!

The patch looks pretty sweet now :). Thank you, @kfritsche!

hchonov’s picture

Status: Needs review » Reviewed & tested by the community

I think the patch is ready. Let's see what the module maintainers think about this.

chr.fritsch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/content_lock.module
@@ -81,8 +81,16 @@ function content_lock_form_alter(&$form, FormStateInterface $form_state, $form_i
+    // This hook function is called twice, first when the form loads
+    // and second when the form is submitted.
+    // Only perform set and check for lock on initial form load.
+    $userInput = $form_state->getUserInput();
+    if (!empty($userInput)) {
+      return;
+    }
+

This was removed in #2912023: Show the lock message after form rebuld.

Everything else looks good to me. Will test it now

hchonov’s picture

Ouch ... good catch!

kfritsche’s picture

Status: Needs work » Needs review
StatusFileSize
new28.23 KB
new1.13 KB

Oh, forgot to merge 8.x-1.x into my dev branch again.

Fixed this now. Also fixed an issue that entity_operations are not working anymore.

chr.fritsch’s picture

Status: Needs review » Needs work
+++ b/content_lock.module
@@ -299,10 +300,15 @@ function content_lock_entity_operation(EntityInterface $entity) {
+        'langcode' => $this->isTranslationLockEnabled($entity_type) ? $entity->language()->getId() : LanguageInterface::LANGCODE_NOT_SPECIFIED,

That's not possible here

hchonov’s picture

That's not possible here

Could you please explain why it is not possible?

chr.fritsch’s picture

$this is not allowed. We are not in object context here

kfritsche’s picture

Status: Needs work » Needs review
StatusFileSize
new28.24 KB
new28.24 KB

And thats why we have reviews ;)
Thanks a lot.

Fixed #14

kfritsche’s picture

StatusFileSize
new754 bytes
chr.fritsch’s picture

Status: Needs review » Needs work

It seems that it doesn't work for me.

What i did:

  1. Installed a site on english
  2. Added german as a second language
  3. Enabled content_translation, conflict and content_lock
  4. Added content translation for my article on admin/config/regional/content-language
  5. Created a second user
  6. Created one article as admin and stay on that articles edit page
  7. Logged in as user 2. Tried to add a translation, that works, but the edit form is still locked
hchonov’s picture

If you've activated translation lock for the node entity type in the content lock settings, then after those steps only the edit form for the default language should be still locked and the edit form for the new translation language should not contain any lock. If this is what you mean by

but the edit form is still locked

then it works as designed. If however the lock is present for the new translation as well could you please ensure that you've enabled translation lock for the node entity type in the content lock settings?

chr.fritsch’s picture

Status: Needs work » Reviewed & tested by the community

Ok, it was my fault. Seems to work. Very nice

  • chr.fritsch committed ce7e43e on 8.x-1.x authored by kfritsche
    Issue #2911532 by kfritsche, hchonov: Lock on entity translation level...
chr.fritsch’s picture

Status: Reviewed & tested by the community » Fixed

Thank you. Thats a very nice feature

hchonov’s picture

Thank you for accepting it!

chr.fritsch’s picture

Status: Fixed » Needs work

Damn, i think we missed an update hook, because we changed the schema.

hchonov’s picture

Well there is no release, just an alpha version :). But if you think that it is necessary then we'll have to update the sql table schema. Should we instead introduce only one update for the language column and for the form operation column being introduced by #2916747: Consider the form operation when locking?

chr.fritsch’s picture

Status: Needs work » Fixed

We have 1500 installations, we need an update hook. I am fine with adding it to #2916747: Consider the form operation when locking

Status: Fixed » Closed (fixed)

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