Comments

joseph.olstad created an issue. See original summary.

joseph.olstad’s picture

StatusFileSize
new285 bytes
joseph.olstad’s picture

Status: Active » Needs review
StatusFileSize
new285 bytes

Status: Needs review » Needs work

The last submitted patch, 3: title_fix_head_tests-3061862-3.patch, failed testing. View results

joseph.olstad’s picture

see my comment here:

#1991988-67: Adding a new translation overwrites the English/source field value

there's a patch that seems to improve the test results from 4 errors down to only 2 errors.

review that please

joseph.olstad’s picture

StatusFileSize
new30.96 KB

here is a revert all the way back to Oct 2017 when the tests used to pass.

just for testing purposes, do not actually use this patch.

joseph.olstad’s picture

Status: Needs work » Needs review

so lets figure out why?

joseph.olstad’s picture

Title: head tests failing with alpha9 » head tests failing since July 2018
stefanos.petrakis’s picture

This is - most probably - caused by #2542826: Language synchronization logic breaks term title translation, in that issue it is reported that the title's tests are broken, however the code changes where committed without fixing the tests (and the source of the breakage in the first place).

joseph.olstad’s picture

Hi Stefanos, thanks for the background info, it will help us pinpoint the test changes needed.

joseph.olstad’s picture

StatusFileSize
new746 bytes

Ok, not sure if this patch will help.

joseph.olstad’s picture

just a hunch, but ya maybe instead of LANGUAGE_NONE we have to look for the default language

Other places in the test results to update

grep LANGUAGE * -R
TitleFieldReplacementTestCase.test:      $entity->{$field_name}[LANGUAGE_NONE][0]['value'] = $label;
TitleTranslationTestCase.test:    entity_translation_get_handler('taxonomy_term', $term)->setOriginalLanguage(LANGUAGE_NONE);
TitleTranslationTestCase.test:      $term->{$field_name}[LANGUAGE_NONE] = $term->{$field_name}[$langcode];
TitleTranslationTestCase.test:    $this->assertTrue($this->checkFieldValues($term, $original_values, LANGUAGE_NONE), 'Term original language correctly changed to the former translation language.');
TitleTranslationTestCase.test:      $term->{$field_name}[$translation_langcode] = $term->{$field_name}[LANGUAGE_NONE];
TitleTranslationTestCase.test:      $term->{$field_name}[LANGUAGE_NONE] = array();
TitleTranslationTestCase.test:    $original_values['name'] = LANGUAGE_NONE . '_' . $this->randomName();
TitleTranslationTestCase.test:    $this->assertEqual($term->{$field_name}[LANGUAGE_NONE][0]['value'], $original_values['name'], 'Untranslatable replacing field on translatable entity correctly handled.');

I changed one , but maybe have to change all of these from LANGUAGE_NONE to the default language using the language_default() function to grab it, then grab the code $langdefault->language

short on time here

Status: Needs review » Needs work

The last submitted patch, 11: D7_title_fix_head_tests-3061862-11.patch, failed testing. View results

joseph.olstad’s picture

StatusFileSize
new2.09 KB

ah maybe not.

ok revert the patch that breaks tests.

joseph.olstad’s picture

StatusFileSize
new2.1 KB

try again

joseph.olstad’s picture

Status: Needs work » Needs review
StatusFileSize
new2.71 KB

ok another patch comming

joseph.olstad’s picture

joseph.olstad’s picture

StatusFileSize
new2.87 KB

this should fix the php 5.3.x and php 5.4.x fails.

joseph.olstad’s picture

StatusFileSize
new2.85 KB

ok minor simplification of code here.

stefanos.petrakis’s picture

Title: head tests failing since July 2018 » Broken tests since commit 8d4ee39 (19.July.2018)
Priority: Normal » Major
Issue summary: View changes

Bumping this to "Major" since it has lots of side-effects, apart from the actual tests failing.

stefanos.petrakis’s picture

joseph.olstad’s picture

stefanos, do you have an opinion on this patch? I'm of the opinion that it's the best thing we have currently. Until something better comes along.

stefanos.petrakis’s picture

Status: Needs review » Needs work

Hi @joseph, I agree, this is the best alternative at the moment. I don't even think there is a better option, hope I am wrong.

Regarding your patch: simply reversing the patch from #2542826: Language synchronization logic breaks term title translation would have been sufficient, however a minor improvement to the tests is not a bad idea, I linked the related issue that caused that error.

I only have one comment:

diff --git a/tests/title_test.module b/tests/title_test.module
index aa60f55..829c257 100644
--- a/tests/title_test.module
+++ b/tests/title_test.module
@@ -87,8 +87,11 @@ function title_test_phase_check($phase, $entity) {
   $label_key = $info['entity keys']['label'];
   $field_name = $label_key . '_field';
   $langcode = LANGUAGE_NONE;
-  if (!empty(entity_language($entity->type, $entity))) {
-    $langcode = entity_language($entity->type, $entity);
+  if (isset($entity->type)) {
+    $entity_language = entity_language($entity->type, $entity);
+    if (!empty($entity_language)) {
+      $langcode = $entity_language;
+    }
   }

Nesting these two ifs could be avoided; you could give $entity_language a default value of NULL and then rewrite this block placing the two ifs one after the other instead of nesting them.

joseph.olstad’s picture

Stefanos, I stand by the nested if, only want to call entity_language() if the entity type is set, otherwise lacking type for entity_language() ?
Not sure how setting $entity_language to NULL will avoid this nesting?

joseph.olstad’s picture

As for the straight up revert see patch 17 in comment 16, php 5.3 and 5.4 fails

stefanos.petrakis’s picture

Here is what I meant:

diff --git a/tests/title_test.module b/tests/title_test.module
index aa60f55..829c257 100644
--- a/tests/title_test.module
+++ b/tests/title_test.module
@@ -87,8 +87,11 @@ function title_test_phase_check($phase, $entity) {
   $label_key = $info['entity keys']['label'];
   $field_name = $label_key . '_field';
   $langcode = LANGUAGE_NONE;
+  $entity_language = NULL;
-  if (!empty(entity_language($entity->type, $entity))) {
-    $langcode = entity_language($entity->type, $entity);
+  if (isset($entity->type)) {
+    $entity_language = entity_language($entity->type, $entity);
+    }
+  if (!empty($entity_language)) {
+      $langcode = $entity_language;
   }
   $value = $entity->{$label_key} == $entity->{$field_name}[$langcode][0]['value'];
   title_test_phase_store($phase, $value);

But, looking at the codes again, I think there is an even simpler rewrite, we don't need empty().

diff --git a/tests/title_test.module b/tests/title_test.module
index aa60f55..829c257 100644
--- a/tests/title_test.module
+++ b/tests/title_test.module
@@ -87,8 +87,11 @@ function title_test_phase_check($phase, $entity) {
   $label_key = $info['entity keys']['label'];
   $field_name = $label_key . '_field';
   $langcode = LANGUAGE_NONE;
-  if (!empty(entity_language($entity->type, $entity))) {
-    $langcode = entity_language($entity->type, $entity);
+  if (isset($entity->type)) {
+    $langcode = entity_language($entity->type, $entity) ?: $langcode;
   }
joseph.olstad’s picture

StatusFileSize
new2.66 KB

hmm, ok, if this patch fails I'll try that.
not even sure if we need the tertiary logic

trying this

diff --git a/tests/title_test.module b/tests/title_test.module
index aa60f55..4e5c211 100644
--- a/tests/title_test.module
+++ b/tests/title_test.module
@@ -87,7 +87,7 @@ function title_test_phase_check($phase, $entity) {
   $label_key = $info['entity keys']['label'];
   $field_name = $label_key . '_field';
   $langcode = LANGUAGE_NONE;
-  if (!empty(entity_language($entity->type, $entity))) {
+  if (isset($entity->type)) {
     $langcode = entity_language($entity->type, $entity);
   }
   $value = $entity->{$label_key} == $entity->{$field_name}[$langcode][0]['value'];

joseph.olstad’s picture

Status: Needs work » Needs review
joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

Stefanos, any objections?

  • ram4nd committed 0525c47 on 7.x-1.x authored by joseph.olstad
    Issue #3061862 by joseph.olstad: Broken tests since commit 8d4ee39 (19....
ram4nd’s picture

Status: Reviewed & tested by the community » Fixed
stefanos.petrakis’s picture

You are right joseph, the tertiary was superfluous, my bad.
Good work!

joseph.olstad’s picture

@stefanos, do you recommend going ahead with a release with this fix?

joseph.olstad’s picture

Thanks @ram4nd , we might as well push a release with this.

Status: Fixed » Closed (fixed)

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