Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blueminds’s picture

Status: Active » Needs review
FileSize
15.1 KB

Here is the patch... however it was a little pain due to the gengo sandbox having some moody behaviour. Also I was not able to submit more than one gengo job so did not get the opportunity to do testing with multiple data items each mapped to remote job. I did a lot of trying but gave up after all :|

Also the patch includes a workaround for https://drupal.org/node/2022147 as without it I was not able to submit a job as invalid data was passed to create mapping.

Status: Needs review » Needs work

The last submitted patch, tmgmt_mygengo-review_data_item_element-2022451-1.patch, failed testing.

blueminds’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, tmgmt_mygengo-review_data_item_element-2022451-1.patch, failed testing.

Berdir’s picture

Category: task » bug

Tests are currently broken, which makes this a bug.

+++ b/tmgmt_mygengo.moduleundefined
@@ -34,7 +34,12 @@ define('TMGMT_MYGENGO_COMMENTS_CACHE_EXPIRE', 900);
+  // @todo - can we rely on this?
+  $parts = explode('|', $target_key);
+  $field = $parts[0];
+  return $form['review'][$field][$target_key]['below'][$gengo_job_id . '_gengo']['comments_wrapper'];

Hm. We probably can, but we shouldn't call it $field.

There's always a first key on that level, maybe $top_key?

It's a bit ugly that we have to know about this here.

+++ b/tmgmt_mygengo.ui.incundefined
@@ -12,125 +12,116 @@
+    $mapping = NULL;
+    foreach ($item->getRemoteMappings() as $mapping) {
+      if ($mapping->data_item_key == $data_item_key) {
+        break;
       }
+      unset($mapping);
+    }
 
-      // Create key which is used in the review form.
-      $key = str_replace('][', '|', $remote->data_item_key);
-      // Add into mapping data array.
-      $remotes[$key] = $remote;
+    // No mapping found for given data item - nothing to do.
+    if (empty($mapping)) {
+      return $form;

Hm. That's a bit hard to understand. We could extend the method and add an optional $data_item_key argument? This might be something that other translators will use too...

Alternatively, I'd prefer a separate variable that is set in the if instead of the unset().

Also, speaking of tests, we have a hen/egg problem here. Apart from the fact that tests are already broken (the testbot just doesn't know yet, but we can change that be forcing the branch to be test), we won't be able get them green, because we now rely on code that is not in alpha3. So to use that, we first need release a new version. But then this module won't work together with that version before we commit it. So I think for now, I'll force a branch test to postpone patches here. Then we need to run tests manually and release both modules at the same time.

blueminds’s picture

please see the patch

$field/$top_key - yes I dont like it as well, it feels fuzzy, but do not think we can do something about it.

$mapping - we pass $data_item_key into the method. Originally I was thinking to pass in whole mapping object, but that might not be ideal for other translators as i.e. for OHT the mapping is job_item specific unlike gengo, where it is data item.

Berdir’s picture

Tested this manually. Noticed a few strange things...

- When requesting a revision, the status icon doesn't update, it stays yellow. After a manual refresh, it's correct.
- The same seems to happen for revisions, the message was displayed but text was not updated, after a refresh it's ok.
- Also had a strange case where all my jobs were suddenly set to needs review, not sure what triggered it exactly.

Did not have any issues with gengo, my jobs showed up there as they're supposed to.

blueminds’s picture

In order to make this work this patch needs to be applied: https://drupal.org/node/2026825#comment-7572663

Status: Needs review » Needs work

The last submitted patch, tmgmt_mygengo-review_data_item_element-2022451-3.patch, failed testing.

blueminds’s picture

Status: Needs work » Needs review

And yes - RE all items in reviewable state - if you save one of the items all of them are submitted and processed via addTranslatedDataRecursive(). In there we do not expect the case when #translation is not set and we skip to logic where we deal with revisions where it is added as empty translation with status TMGMT_DATA_ITEM_STATE_TRANSLATED. Created followup Issue #2026849 to deal with it.

blueminds’s picture

Status: Needs review » Needs work

The last submitted patch, tmgmt_mygengo-review_data_item_element-2022451-3.patch, failed testing.

blueminds’s picture

this is really strange, locally tests are passing...

Berdir’s picture

No, not strange at all :)

See last paragraph in #5.

The testbot uses the latest release of tmgmt core, which doesn't have those methods yet, so nothing is added to the form and the tests fail.

To make the tests pass, I need to release a new alpha/beta of core, then commit this and then create a release for this.

Berdir’s picture

Run the tests locally, still getting some notice exceptions?

Undefined index: ajaxid Notice tmgmt_mygengo.ui.inc 87 TMGMTMyGengoTranslatorUIController->reviewDataItemElement()

blueminds’s picture

Status: Needs review » Needs work

The last submitted patch, tmgmt_mygengo-review_data_item_element-2022451-4.patch, failed testing.

Berdir’s picture

Status: Needs work » Fixed

thanks, committed and pushed. Opened #2032869: Remove update is ignored if text did not change and data item is in pending state for the core bug that I found.

Status: Fixed » Closed (fixed)

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