In SqlContentEntityStorage the revision_log, revision_timestamp and revision_uid are marked as revision metadata fields, which means they cannot be translatable.

The revision_log is only used by two entities: Node and BlockContent. Only on the node entity it is marked as translatable.

This causes a problem in the following use case:

  1. create a node entity in english translation
  2. add a german translation to it
  3. edit the german translation and set a revision_log while on the german translation
  4. save the entity
  5. load the entity
  6. the revision log message is missing on both translations

So the revision_log on the node entity should be marked as untranslatable.

I have attached a patch for this issue.

Comments

hchonov’s picture

penyaskito’s picture

Status: Needs review » Needs work
Issue tags: +D8MI, +sprint, +language-content

Makes sense to me, good catch!
I don't see any use case where we could want to translate the revision log.

Can you provide a failing test?

gábor hojtsy’s picture

Issue tags: +Needs tests

I agree this looks good. Not 100% sure how would this be tested? Retrieve the metadata of the node fields and verify the revision log is not translatable looks fine to me.

maxocub’s picture

Status: Needs work » Needs review
StatusFileSize
new1.46 KB
new901 bytes

Is it sufficient to test that revision_log is not translatable or should we test that revision_log is not lost after editing the translation of a node?

The last submitted patch, 4: 2480921-4.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 4: test-only.patch, failed testing.

maxocub queued 4: 2480921-4.patch for re-testing.

The last submitted patch, 4: 2480921-4.patch, failed testing.

The last submitted patch, make_node_entity_revision_log_untranslatable.patch, failed testing.

maxocub’s picture

Seems like making the revision log not translatable now breaks quickedit. Concurrently editing a node with the full form and the quickedit form doesn't throw an error.
I'm trying to reproduce this bug and the expected behavior from the UI and I haven't succeeded yet.

RavindraSingh’s picture

Assigned: Unassigned » RavindraSingh
RavindraSingh’s picture

Status: Needs work » Needs review
StatusFileSize
new627 bytes

I just want to make sure if I update ->setTranslatable(TRUE) to FALSE then if throws the error or not. then I will add the tests. I have run the tests on local. it got passed.

Status: Needs review » Needs work

The last submitted patch, 13: 2480921-revision-log.patch, failed testing.

hchonov’s picture

I made some testing and actually found the commit since which the QuickEditLoadingTest::testConcurrentEdit fails if we set the node revision_log as non translatable.

Reverting to the commit previous to #2428795: Translatable entity 'changed' timestamps are not working at all makes the test pass.

hchonov’s picture

And more specifically the problem occurs since the changes in ChangedItem::preSave

hchonov’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB

And the problem is that the ChangedItem now has a new logic -> it checks if the entity has changed and only in this case will update the changed timestmap. But in the test we open the node edit page and save the the node without any changes => which does not update the changed timestamp and so there was no concurrent edit.

Uploading a patch which should pass now.

hchonov’s picture

And here the patch with the test included.

hchonov’s picture

Assigned: RavindraSingh » Unassigned
plach’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, thanks!

hchonov’s picture

Status: Reviewed & tested by the community » Postponed
Related issues: +#2506213: Update content entity changed timestamp on UI save

Postponing on #2506213: Decide how the changed timestamp should behave on UI save as the change I made in the test might not be neccessary for the entity to be updated and before commiting such a change it should first be decided what to do when posting an entity form without any changes. The test change might or might not be neccessary.

gábor hojtsy’s picture

Issue tags: -sprint

There is no movement on #2506213: Update content entity changed timestamp on UI save for over a month, so removing from sprint :/

mkalkbrenner’s picture

plach’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/content_translation/src/Tests/ContentTranslationStandardFieldsTest.php
    @@ -77,4 +77,12 @@ public function testFieldTranslatableArticle() {
    +  }
    

    Missing empty line after closing brace.

  2. +++ b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
    @@ -502,8 +502,11 @@ public function testConcurrentEdit() {
    -      // Save the node on the regular node edit form.
    -      $this->drupalPostForm('node/1/edit', array(), t('Save'));
    +      // Save the node on the regular node edit form. Saving the node without
    +      // any changes will not update the changed timestamp, as the ChangedItem
    +      // now has a logic to check if the entity changed and only then update its
    +      // value. Thus we have to force update the node entity.
    +      $this->drupalPostForm('node/1/edit', array('changed' => time()), t('Save'));
    

    I think this can be removed now.

hchonov’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.46 KB

@plach:

1. added an empty line.
2. yes, since #2506213: Update content entity changed timestamp on UI save was just commited the change in the QuickEditLoadingTest is not needed anymore.

plach’s picture

Status: Needs review » Needs work
+++ b/core/modules/content_translation/src/Tests/ContentTranslationStandardFieldsTest.php
@@ -77,4 +77,13 @@ public function testFieldTranslatableArticle() {
+    $this->assertNoFieldByXPath("//input[@id='edit-settings-node-article-fields-revision-log']");
+  }
+  ¶
 }

Trailing white-space, we cannot let that sneak in, sorry :)

plach’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.46 KB

Removed the white space, no credits, please.

plach’s picture

Issue tags: +rc target
gábor hojtsy’s picture

Issue tags: +sprint

Bring it back on sprint for tracking then :)

plach’s picture

Priority: Normal » Major

This looks majorish

alexpott’s picture

Issue tags: -rc target +rc deadline
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4a99201 and pushed to 8.0.x. Thanks!

  • alexpott committed 4a99201 on 8.0.x
    Issue #2480921 by hchonov, maxocub, plach, RavindraSingh, Gábor Hojtsy:...
gábor hojtsy’s picture

Issue tags: -sprint

Superb, thanks all!

Status: Fixed » Closed (fixed)

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

maxocub’s picture

maxocub’s picture