When source has the status EDITED and then a target translation is downloaded the target status is set to CURRENT (see https://www.drupal.org/node/2780933 , it should be NOT_CURRENT) this behavior is not specifically mentioned in the Lingotek Connector Requirements document but rather in the ticket https://www.drupal.org/node/2780933 and the Source status is set to CURRENT even though an outdated target translation is downloaded and has nothing to do with the source, the expected behavior would be for the source status to stay the same. According to the Lingotek Connector Requirements the only action to set the Source state to CURRENT is the successful upload of the source to the TMS.

CommentFileSizeAuthor
#47 source_and_target_set_to_current-2850528-48.patch20.42 KBt.murphy
#47 source_and_target_set_to_current-2850528-48.only-tests.patch16.84 KBt.murphy
#45 source_and_target_set_to_current-2850528-45.patch20.51 KBt.murphy
#45 source_and_target_set_to_current-2850528-45.only-tests.patch16.93 KBt.murphy
#42 source_and_target_set_to_current-2850528-42.patch20.5 KBt.murphy
#42 source_and_target_set_to_current-2850528-42.only-tests.patch16.93 KBt.murphy
#39 source_and_target_set_to_current-2850528-39.patch20.51 KBt.murphy
#39 source_and_target_set_to_current-2850528-39.only-tests.patch16.94 KBt.murphy
#36 source_and_target_set_to_current-2850528-36.patch20.51 KBt.murphy
#36 source_and_target_set_to_current-2850528-36.only-tests.patch16.94 KBt.murphy
#33 source_and_target_set_to_current-2850528-33.patch20.61 KBpenyaskito
#33 source_and_target_set_to_current-2850528-33.only-tests.patch17.03 KBpenyaskito
#30 source_and_target_set_to_current-2850528-30.patch20.61 KBt.murphy
#28 source_and_target_set_to_current-2850528-28.patch20.47 KBt.murphy
#26 source_and_target_set_to_current-2850528-26.patch19.79 KBt.murphy
#24 source_and_target_set_to_current-2850528-24.patch19.79 KBt.murphy
#23 source_and_target_set_to_current-2850528-23.patch13.02 KBt.murphy
#21 source_and_target_set_to_current-2850528-21.patch14.15 KBt.murphy
#19 source_and_target_set_to_current-2850528-19.patch13.02 KBt.murphy
#17 source_and_target_set_to_current-2850528-17.patch14.15 KBt.murphy
#15 source_and_target_set_to_current-2850528-15.patch8.05 KBt.murphy
#11 source_and_target_set_to_current-2850528-11.patch9.14 KBt.murphy
#9 source_and_target_set_to_current-2850528-9.patch9.16 KBt.murphy
#7 source_and_target_set_to_current-2850528-7.patch9.55 KBt.murphy
#4 source_and_target_set_to_current-2850528-4.patch3.27 KBt.murphy
#2 source_and_target_set_to_current-2850528-2.patch3.58 KBt.murphy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

t.murphy created an issue. See original summary.

t.murphy’s picture

Status: Needs review » Needs work

The last submitted patch, 2: source_and_target_set_to_current-2850528-2.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
3.27 KB
t.murphy’s picture

Status: Needs review » Reviewed & tested by the community
penyaskito’s picture

Status: Reviewed & tested by the community » Needs work

I would love a test showing this bug, so we can ensure we are fixing it.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
9.55 KB

Status: Needs review » Needs work

The last submitted patch, 7: source_and_target_set_to_current-2850528-7.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
9.16 KB

Status: Needs review » Needs work

The last submitted patch, 9: source_and_target_set_to_current-2850528-9.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
9.14 KB
t.murphy’s picture

There is now a working test for this that ensures the problem is being fixed.

penyaskito’s picture

Status: Needs review » Needs work
  1. +++ b/src/LingotekConfigTranslationService.php
    @@ -509,11 +509,22 @@ class LingotekConfigTranslationService implements LingotekConfigTranslationServi
    +        // Deprecated  "|| $source_status == Lingotek::STATUS_EDITED" from
    +        // if statment because if the source status is EDITED then it has
    +        // not been uploaded again and so a target translation could be
    +        // ready for download and then be downloaded but the source remains
    +        // EDITED and should not be changed to CURRENT
    
    +++ b/src/LingotekContentTranslationService.php
    @@ -598,10 +598,21 @@ class LingotekContentTranslationService implements LingotekContentTranslationSer
    +            // Deprecated  "|| $source_status == Lingotek::STATUS_EDITED" from
    +            // if statment because if the source status is EDITED then it has
    +            // not been uploaded again and so a target translation could be
    +            // ready for download and then be downloaded but the source remains
    +            // EDITED and should not be changed to CURRENT
    +            if ($source_status == Lingotek::STATUS_IMPORTING) {
    

    I don't think we need these comments. We can add one in the if clause explaining the code, but IMHO we shouldn't explain code that we are removing.

  2. +++ b/src/LingotekConfigTranslationService.php
    @@ -509,11 +509,22 @@ class LingotekConfigTranslationService implements LingotekConfigTranslationServi
    +        if ($source_status == Lingotek::STATUS_EDITED && $status) {
    +          $this->setTargetStatus($entity, $langcode, Lingotek::STATUS_EDITED);
    +        }
    +        elseif ($source_status == Lingotek::STATUS_EDITED && !$status) {
    +          $this->setTargetStatus($entity, $langcode, Lingotek::STATUS_EDITED);
    +        }
    
    +++ b/src/LingotekContentTranslationService.php
    @@ -598,10 +598,21 @@ class LingotekContentTranslationService implements LingotekContentTranslationSer
    +            if ($source_status == Lingotek::STATUS_EDITED && $status) {
    +              $this->setTargetStatus($entity, $langcode, Lingotek::STATUS_EDITED);
    +            }
    +            elseif ($source_status == Lingotek::STATUS_EDITED && !$status) {
    +              $this->setTargetStatus($entity, $langcode, Lingotek::STATUS_EDITED);
    +            }
    

    These ones could be simplified to

    if ($source_status == Lingotek::STATUS_EDITED)
    

    Do we need the same logic in downloadConfig()?

  3. +++ b/src/Tests/LingotekNodeStatusDownloadTargetTest.php
    @@ -0,0 +1,133 @@
    +class LingotekNodeStatusDownloadTargetTest extends LingotekTestBase {
    

    We would need the same test for a config entity and a config object for ensuring that we have proper coverage. We are only covering content here, and we already had issues maintaining those in sync (at some point we should unify this logic and remove code duplication for content entities, config entities and config objects)

penyaskito’s picture

+++ b/src/Tests/LingotekNodeStatusDownloadTargetTest.php
@@ -0,0 +1,133 @@
+    $source_current = $this->xpath("//a[contains(@class,'language-icon') and contains(@class, 'source-current')  and contains(text(), 'EN')]");
+    $this->assertEqual(count($source_current), 0, 'Source is not marked as current.');
+    $es_current = $this->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-current')  and contains(text(), 'ES')]");
+    $this->assertEqual(count($es_current), 0, 'Spanish is not marked as current.');

Also, let's assert positively. Instead of asserting that the status is not current, let's assert for the status we actually expect it to be.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
8.05 KB

Status: Needs review » Needs work

The last submitted patch, 15: source_and_target_set_to_current-2850528-15.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
14.15 KB

Status: Needs review » Needs work

The last submitted patch, 17: source_and_target_set_to_current-2850528-17.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
13.02 KB

Status: Needs review » Needs work

The last submitted patch, 19: source_and_target_set_to_current-2850528-19.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
14.15 KB

Status: Needs review » Needs work

The last submitted patch, 21: source_and_target_set_to_current-2850528-21.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
13.02 KB
t.murphy’s picture

Status: Needs review » Needs work

The last submitted patch, 24: source_and_target_set_to_current-2850528-24.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
19.79 KB

Status: Needs review » Needs work

The last submitted patch, 26: source_and_target_set_to_current-2850528-26.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
20.47 KB

Status: Needs review » Needs work

The last submitted patch, 28: source_and_target_set_to_current-2850528-28.patch, failed testing.

t.murphy’s picture

Status: Needs work » Needs review
FileSize
20.61 KB
penyaskito’s picture

Status: Needs review » Needs work

src/Tests/LingotekNodeStatusDownloadTargetTest.php already exists, so this patch doesn't apply anymore, could you reroll it?

penyaskito’s picture

I had this locally, I need to try again.

penyaskito’s picture

Splitting the patch for having one with only the tests, so ensures that we are adding coverage to this issue. Patch is exactly the same.

The last submitted patch, 33: source_and_target_set_to_current-2850528-33.only-tests.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 33: source_and_target_set_to_current-2850528-33.patch, failed testing.

t.murphy’s picture

The last submitted patch, 36: source_and_target_set_to_current-2850528-36.only-tests.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 36: source_and_target_set_to_current-2850528-36.patch, failed testing.

t.murphy’s picture

The last submitted patch, 39: source_and_target_set_to_current-2850528-39.only-tests.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 39: source_and_target_set_to_current-2850528-39.patch, failed testing.

t.murphy’s picture

The last submitted patch, 42: source_and_target_set_to_current-2850528-42.only-tests.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 42: source_and_target_set_to_current-2850528-42.patch, failed testing.

t.murphy’s picture

Status: Needs review » Needs work

The last submitted patch, 45: source_and_target_set_to_current-2850528-45.patch, failed testing.

t.murphy’s picture

The last submitted patch, 47: source_and_target_set_to_current-2850528-48.only-tests.patch, failed testing.

t.murphy’s picture

Tests have been updated and it is expected for the only-tests patch would fail because in order to pass it needs the code changes from the patch.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me.

  • penyaskito committed 3d9564f on 8.x-2.x authored by t.murphy
    Issue #2850528 by t.murphy, penyaskito: Source and Target are set to...
penyaskito’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3d9564f and pushed to 8.x-2.x. Thanks!

Status: Fixed » Closed (fixed)

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